Page 1 of 1

Unidac - SQLite - VACUUM Into

Posted: Thu 03 Feb 2022 12:42
by chrishead
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?

Re: Unidac - SQLite - VACUUM Into

Posted: Tue 08 Feb 2022 13:53
by MaximG
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;
...

Re: Unidac - SQLite - VACUUM Into

Posted: Wed 16 Feb 2022 11:38
by chrishead
Thank you!

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

Re: Unidac - SQLite - VACUUM Into

Posted: Thu 17 Feb 2022 14:05
by MaximG
We are glad that you found a necessary solution. Please don't hesitate to contact us with questions concerning UniDAC usage.