#1 2019-06-02 10:23:22

Horbs
Member
Registered: 2014-04-20
Posts: 22

VirtualTableExternalRegisterAll and Auth Tables - SQLite

I'm currently implimenting Buisness Administration functionality to an almost completed Booking System project using mORMot and SQLite.

The Client uses a web javascript front end, and the Admin functions will be provided by a Delphi VCL Client (doing that now). I've just started to impliment User Management, and I'm confused regarding errors with the TSQLAuthGroup, TSQLAuthUser tables with respect to VirtualTableExternal and CreateMissingTables.

The server side code is :

  {1}  DBProps := TSQLDBSQLite3ConnectionProperties.Create('PopitBookings.DB3','','','');
  {2}  Model := CreateSampleModel;
  {3}  VirtualTableExternalRegisterAll(Model, DBProps);
  {4}  PopitDB := TSQLRestServerDB.Create(Model, 'PopitBookings.db3', False);
  {5}  PopitDB.CreateMissingTables; // error here
  ...

Prior to implementing the Auth tables, I could delete the Bookings.db3 file and, on running the server, a new database was created as expected.

After adding the Auth Tables - Model Creation is now :

  TSQLModel.Create([TSQLAuthGroup, TSQLAuthUser, and the other 7 tables ... ]);

And now I get an exception after Line 5 (CreateMissingTables) that tells me the Database is busy :
  "Error SQLITE_BUSY using 3.28.0 - database is locked ...".

If I omitt line 3, the Auth tables are created as part of the database, but not populated wit Auth records.

I've read the SAD over and over, but have had no success in figuring out how to resolve this issue, or understanding why my approach is wrong.

Any help/advice would be greatly appreciated (mORMot version : 1.18.5232).

Last edited by Horbs (2019-06-02 10:27:04)

Offline

#2 2019-06-03 07:43:04

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,240
Website

Re: VirtualTableExternalRegisterAll and Auth Tables - SQLite

"Database is locked" is triggered since you open the database file twice.
Once in DBProps, then twice in PopitDB.

Use SQLITE_MEMORY_DATABASE_NAME for PopitDB.

Offline

#3 2019-06-04 06:14:52

Horbs
Member
Registered: 2014-04-20
Posts: 22

Re: VirtualTableExternalRegisterAll and Auth Tables - SQLite

Thank you AB - that fixed it.

But still had a problem in that the Auth tables were empty.

Fixed by moving "Model := CreateSampleModel;" to the first line.

Horbs

Offline

Board footer

Powered by FluxBB