Page 1 of 1

How to call "Vacuum" from Delphi code

Posted: Sat 09 Feb 2013 13:40
by JayM
I need to call Vacuum in Delphi code (Delphi 2007, LiteDac Professional 1.6.4, registered). During development, I am not using "Direct Mode" but eventually I will use this as database needs to be encrypted.

I have seen the following code on one of the forum posts.

Code: Select all

PRAGMA page_size=16384;
VACUUM;
My Data Module "Uses" the following units but obviously that is not enough:
DB, DBAccess, LiteAccess, MemDS

I have TLiteConnection and TLiteQuery components on the Data Module. (No other LiteDac components are on Data Module.)

In which unit are Vacuum and PRAGMA_xyz declared?
Which object does the "Vacuum" procedure/function belong to, if any?


Thank You

JayM

Re: How to call "Vacuum" from Delphi code

Posted: Mon 11 Feb 2013 13:49
by AlexP
Hello,

PRAGMA and VACUUM are the SQLite commands, therefore they are absent in our modules. So, to run them, you can use any components allowing to run commands, for example:

Code: Select all

  LiteConnection1.ExecSQL('PRAGMA page_size=16384');
  LiteConnection1.ExecSQL('VACUUM');
or

Code: Select all

  LiteQuery1.SQL.Text := 'PRAGMA page_size=16384';
  LiteQuery1.Execute;
  LiteQuery1.SQL.Text := 'VACUUM';
  LiteQuery1.Execute;

Re: How to call "Vacuum" from Delphi code

Posted: Tue 12 Feb 2013 01:37
by JayM
Thank you very much.

I am posting SIMILAR question regarding how to call "Repair", "ReIndex" and "Backup" from Delphi code. If there is documentation regarding these issues, please point me in the right direction so that I stop bothering you on the forum.

Re: How to call "Vacuum" from Delphi code

Posted: Tue 12 Feb 2013 11:08
by AlexP
Hello,

The REINDEX method can be called similarly to the PRAGMA and VACUUM methods. For the time being, the SQLite Online Backup API engine is not implemented in LiteDAC. Therefore, presently, to restore the DB, you can use the SQLite3.exe console utility.