Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2020-09

Project SQLite for pas2js

8 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

warleyalex

After the SQLite database Chinook_Sqlite.sqlite (1,067KB) is loaded, we can use any SQL statement.
for 1st button: if click on the row track, it will load the dataset track, in 2nd button: we have datatable feature.
------------------------------------------------------------------------------ live preview: https://pas2js.github.io/master/projSQL/index.html download project: https://pas2js.github.io/master/projSQL/projSQL.rar

Reply by email

Mgr. Janusz Chmiel
to warleyalex

Dear MR warley,
Thank you very much for this project. Do you think, that this project could be even used for writing and reading to The Mysql database which resides on server? Or it would be too complex to manage? Thank you for yours answer.

Reply by email

Michael Van Canneyt
to Mgr. Janusz Chmiel
Mgr. Janusz Chmiel wrote
Dear MR warley, Thank you very much for this project. Do you think, that this project could be even used for writing and reading to The Mysql database which resides on server? Or it would be too complex to manage?

No, that requires a different technology altogether. Usually this is done through some REST mechanism.

For example, one such technology is:
https://wiki.freepascal.org/SQLDBRestBridge

Michael.

Reply by email

warleyalex
to warleyalex

OK, It is a bit of investigation, and no need to Disable Cache at developer tools,

Look at the following method (the fetch method with the object initialization {cache: "no-store"})

{  Open Async local Sqlite Database file }
procedure OpenSQLiteDBFile(path: String; callBackDB: TProcedureSQLDB);
async;
var
  fetched: TJSResponse;
  buf: TJSPromise; //TJSArrayBuffer;
  dataDB: TJSUint8Array;
begin
  fetched := await(window.fetch( path, new(['cache', 'no-store']) ));
  buf := await (fetched.arrayBuffer());
  dataDB:= TJSUint8Array.New( TJSArrayBuffer(buf) );
  callBackDB( TJSSqliteDatabase.New( dataDB ));
end;
By the way, I had to edit web.pas, I think the correct definition of the
following method would be correct;
function fetch(resource: String; init: TJSObject): TJSResponse;
{TJSPromise;} overload; external name 'fetch';

Reply by email

Michael Van Canneyt
to warleyalex
warleyalex wrote 26 lines
OK, It is a bit of investigation, and no need to Disable Cache at developer tools, Look at the following method (the fetch method with the object initialization {cache: "no-store"}) { Open Async local Sqlite Database file } procedure OpenSQLiteDBFile(path: String; callBackDB: TProcedureSQLDB); async; var fetched: TJSResponse; buf: TJSPromise; //TJSArrayBuffer; dataDB: TJSUint8Array; begin fetched := await(window.fetch( path, new(['cache', 'no-store']) )); buf := await (fetched.arrayBuffer()); dataDB:= TJSUint8Array.New( TJSArrayBuffer(buf) ); callBackDB( TJSSqliteDatabase.New( dataDB )); end; By the way, I had to edit web.pas, I think the correct definition of the following method would be correct; function fetch(resource: String; init: TJSObject): TJSResponse; {TJSPromise;} overload; external name 'fetch';

Fetch returns a promise, not a TJSResponse.

See

https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch

So you will at least need an async modifier if you want to have it return a 'JSResponse'

But for backwards compatibility, this cannot be added with the name 'fetch'.

So I have added it with the name asyncfetch.

Michael.

Reply by email