|
AnyDAC
|
The class implementing SQLite backup, restore, copy database functionality.
uADPhysSQLite
Use the TADSQLiteBackup component to add a backup, restore, copy database capability to an application.
To produce a DB backup an application should:
Other properties and methods are optional.
The SQLite backup actually copies the specified database to a new file. The copying is consistent and does not depend on the currently connected users.
Also the copying may be performed not only between files, but also between memory and file or backward. In this case use DatabaseObj or DestDatabaseObj to specify connected memory database.
TADSQLiteBackup = class(TADSQLiteService);
ADSQLiteBackup1.Database := 'c:\addemo.sdb'; ADSQLiteBackup1.DestDatabase := 'c:\addemo.backup'; ADSQLiteBackup1.Backup;
// create SQLite in-memory database with ADConnection1.Params do begin Clear; Add('DriverID=SQLite'); Add('Database=:memory:'); end; ADConnection1.Connected := True; // populate the in-memory database ADConnection1.ExecSQL('create table aaa (f1 integer, f2 text)'); ADConnection1.ExecSQL('insert into aaa values (1, ''qqq'')'); ADConnection1.ExecSQL('insert into aaa values (2, ''www'')'); ADConnection1.ExecSQL('insert into aaa values (3, ''eee'')'); // specify the in-memory database objects as a backup source ADSQLiteBackup1.DatabaseObj := ADConnection1.CliObj;
// specify database file name as a backup destination ADSQLiteBackup1.DestDatabase := 'c:\db.sdb'; // copy the in-memory database to the file
ADSQLiteBackup1.Backup;
|
What do you think about this topic? Send feedback!
|