How to find out new blank database

When I start a new install of my application it will create the databases needed.

I am not sure how to do that with RemoteDB and native SQLite.

In ElevateDB i have the following:

function TNaharElevateDBConnectionAdapter.IsDatabaseEmpty: Boolean;
  result := true;

  if Assigned(FEDBSession) then
    if FEDBSession.Execute('select * from databases where name = '+QuotedStr(DatabaseName)) > 0 then
      if FEDBDatabase.Execute('select * from information.tables') > 0 then
        result := False;

that works for me, using their catalog that can be queried.

However for ElevateDB I have their component at this moment (TEDBDatabase) and I can use it for a query.

With the other 2, I only have the IDBConnection that was already constructed.

Can you give me hint on how can I do that? (eventually little bit off-topic, but ..... )



I was not clear in my question, sorry.

I create the database using the proper aurelius adapter, just fine.

THe adapter will make the DB create the database (not the case for ElevateDB that is previously created)

But it is the case for SQLite and maybe for RemoteDB

With ElevateDB I have it empty but I can query the catalog and find out that there is not tables yet, then I can create them.

I dont know what to do with SQLite, since I only got IDBConnection at that level of my classes;

Same problem with remoteDB. I am using ElevateDB for my RemoteDB server, can I query the catalog over it also?


Why do you want to do that? You can use UpdateDatabase and Aurelius will do all the job for you (query catalog and create missing tables).

Nevertheless you can get back the original component used by the IDBConnection interface casting it back to original adapter class and reading Connection property (this was included in latest version, check "what's new" in manual).

well, maybe I am wrong doing that, however my intent was to not go to expensive checking if the database is already there and the current installation is not allowed to update the database.

Since it is a multi-user multi-store system I cant just let any station updating the database. When a new version is available the admin, will manage to run the application from one place with the config permission to update the database. 

And not to forget there is locking issues. So, that is way I check first.

If the database is somehow blank then I need to say to the user. 

Based in what you said, I came up with the idea, if I use UpdateDatabase with SQLExcutioinEnabled = false and check the errorcount I could have the functionality i want: find out if the database is ready or  not ready?


I found:

Note that when SQLExecutionEnabled property is false, calling UpdateDatabase
is equivalent to calling ValidateDatabase, so this code:


  // Output an SQL script to update the existing database

  DBManager.SQLExecutionEnabled := false;




Could also be written just as:


  // Output an SQL script to update the existing database

  // Regardless of value of SQLExecutionEnabled property



that answer all my needs. Thank you

yes, you can do that. There are plenty ways, and they are documented. If only your admin can update the database, why do you need to do automatic check? You can just call UpdateDatabase and that's it.

Yes, you can do verification of database without executing the sql statements, as stated in documentation.
Also, you can just perform a Find<T> on any class and check for exceptions (if table does not exist, an exception is raised).
Also, if you want to check it by yourself, you can execute SQL statements by using IDBConnection.CReateStatement interface. That's the low level mechanism Aurelius use to execute SQL statements and it's available to you.
Finally, again, you can still retrieve the original component you used to create the IDBConnection (be it TFDConnection, TEDBDatabase, etc.).