Unidac - SQLite - VACUUM Into

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
chrishead
Posts: 2
Joined: Thu 03 Feb 2022 12:07

Unidac - SQLite - VACUUM Into

Post by chrishead » Thu 03 Feb 2022 12:42

Hi!

I'm trying use "VACUUM into" function in SQLite Direct mode, but I couldn´t find the solution, I always got errors.
if I try this:

Code: Select all

vacuum main into 'C:\\Users\\Fejleszto\\Documents\\test123.db'
I got:

Code: Select all

Unable to open database: C:\\Users\\Fejleszto\\Documents\\test123.db
I tried all variation of file name, like single backslash, relative path, but I didn´t found the solution.

If i changed direct mode to false I got "syntax error near [into]" exception.

I tested in Firedac and sqlite manager, there was a successful result.

Do you have any idea, which is wrong?

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Unidac - SQLite - VACUUM Into

Post by MaximG » Tue 08 Feb 2022 13:53

To execute the VACUUM command in the Direct mode, use the ForceCreateDatabase option :

Code: Select all

...
  UniConnection: TUniConnection;
begin
  UniConnection := TUniConnection.Create(nil);
  try
    UniConnection.ProviderName := 'SQLite';
    UniConnection.Database := 'C:\Users\Fejleszto\Documents\test.db';
    UniConnection.SpecificOptions.Values['Direct'] := 'True';
    UniConnection.SpecificOptions.Values['ForceCreateDatabase'] := 'True';
    UniConnection.Connect;
    UniConnection.ExecSQL('VACUUM main INTO ''C:\\Users\\Fejleszto\\Documents\\test123.db''');
  finally
    UniConnection.Free;
  end;
...

chrishead
Posts: 2
Joined: Thu 03 Feb 2022 12:07

Re: Unidac - SQLite - VACUUM Into

Post by chrishead » Wed 16 Feb 2022 11:38

Thank you!

(I found an another solution, when i created an empty file with same name before call VACUUM.)

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Unidac - SQLite - VACUUM Into

Post by MaximG » Thu 17 Feb 2022 14:05

We are glad that you found a necessary solution. Please don't hesitate to contact us with questions concerning UniDAC usage.

Post Reply