Run Command on startup

(Matthew Vesperman) #1


I am trying to run a sql script against a database in a Data Abstract server to make sure that the schema exists. (UniDAC connection to SQLite database). The database is auto-created by UniDAC if it doesn’t exist upon first connection (this is due to using UniDAC’s encryption for the database file).

Any suggestions as to how to accomplish this task?

My first thought is for there to be a flag in the data module that will indicate if the process has already occurred. Set it to false in the data module’s OnCreate handler.

Then in the ConnectionManager’s OnConnectionCreated handler check the flag. If it is false then run the sql script agains the connection. My question boils down to how do I execute a SQL script on the connection interface in that handler?


(EvgenyK) #2

you can set DAConnectionManager.MaxPoolSize to 1.
once database is created, you can change this value to default one.

you can get access to TUniConnection like

uni:=TUniConnection((Connection as IDAConnectionObjectAccess).ConnectionObject);

with TUniConnection object, you should be able to create your database file.