You are not logged in.
Pages: 1
Hello,
I'm trying to make an in-memory SQLite3 database accessible via HTTP but it doesn't seem to be working.
I use the code below to create the in-memory database when I undefine SQLITE_DB_ON_DISK
{$IFDEF SQLITE_DB_ON_DISK}
DBServer := TSQLRestServerDB.Create(Model, DBNAME, {$IFDEF AUTHENTICATION}True{$ELSE}False{$ENDIF});
{$ELSE}
DBServer := TSQLRestServerDB.Create(Model, ':memory:', {$IFDEF AUTHENTICATION}True{$ELSE}False{$ENDIF});
{$ENDIF}
DBServer.CreateMissingTables;
//
// Create the HTTP Server
// Register URI first otherwise error is thrown
{$IFDEF SQLITE_DB_ON_DISK}
Server := TSQLHttpServer.Create(DEFAULT_HTTP_PORT, [DBServer], '+', HTTP_DEFAULT_MODE);
{$ELSE}
Server := TSQLHttpServer.Create(DEFAULT_HTTP_PORT, [], '+', HTTP_DEFAULT_MODE);
{$ENDIF}
Server.AccessControlAllowOrigin := '*'; // allow cross-site AJAX queries
if I use [':memory:'] with the HTTP server like this,
Server := TSQLHttpServer.Create(DEFAULT_HTTP_PORT, [':memory:'], '+', HTTP_DEFAULT_MODE)
the compiler says there is no overloaded version of 'Create' that can be called with these arguments.
What do I need to correct?
Thanks a lot.
Last edited by JD (2017-09-28 14:39:12)
Offline
Thanks a lot ab. It worked!!!
However, I assumed that the data created when the model was created will be stored in memory. I had created a table Genre with the following initial data in the model
// Add default record for the genre table
if DBClient.TableRowCount(TSQLGenre) = 0 then
begin
Genre := TSQLGenre.Create;
//
try
Genre.Description := UTF8ToString('Feminin');
Genre.CreationBy := TSQLUtilisateur(1);
DBClient.Add(TSQLRecord(Genre), True);
Genre.Description := UTF8ToString('Masculin');
Genre.CreationBy := TSQLUtilisateur(1);
DBClient.Add(TSQLRecord(Genre), True);
finally
Genre.Free;
end;
end; // if DBClient.TableRowCount(TSQLGenre) = 0
When I save the DB on disk and then access the table from the browser, I get the JSON result [{"ID":1},{"ID":2}], which is correct BUT when the DB is in memory, browser access returns the JSON result {"fieldCount":1,"values":["ID"],"rowCount":0} which is not correct! What am I doing wrong while accessing my in-memory DB?
Thanks a lot,
JD
Offline
Pages: 1