How to call "Vacuum" from Delphi code

Discussion of open issues, suggestions and bugs regarding LiteDAC (SQLite Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
JayM
Posts: 4
Joined: Sun 20 Jun 2010 17:25

How to call "Vacuum" from Delphi code

Post by JayM » Sat 09 Feb 2013 13:40

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: How to call "Vacuum" from Delphi code

Post by AlexP » Mon 11 Feb 2013 13:49

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;

JayM
Posts: 4
Joined: Sun 20 Jun 2010 17:25

Re: How to call "Vacuum" from Delphi code

Post by JayM » Tue 12 Feb 2013 01:37

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.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: How to call "Vacuum" from Delphi code

Post by AlexP » Tue 12 Feb 2013 11:08

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.

Post Reply