Recent

Author Topic: SQLite vacuum and SqlDB components  (Read 3963 times)

kpeters58

  • Sr. Member
  • ****
  • Posts: 267
SQLite vacuum and SqlDB components
« on: June 07, 2013, 05:53:28 pm »
Hi,

How does one vacuum a SQLite database from a SqlDB component?

I either get 'cannot vacuum from with transaction' or  'transaction not set' - seems like a catch 22 to me. Please suggest only something known to work - I just went through quite a number of (obviously untested and thus not working) suggestions....

Thanks for all input,
Kai
Lazarus 2.0.4/FPC 3.0.4/Win 64

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: SQLite vacuum and SqlDB components
« Reply #1 on: June 07, 2013, 06:47:36 pm »
You can't sqlDB does not work outside of a transaction. You have to use a SQLite specific component and see if that can do it or use the API directly.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

parcel

  • Full Member
  • ***
  • Posts: 143
Re: SQLite vacuum and SqlDB components
« Reply #2 on: June 08, 2013, 12:52:50 am »
Sqlitepass may help you.

http://source.online.free.fr/

Pascaluvr

  • Full Member
  • ***
  • Posts: 216
Re: SQLite vacuum and SqlDB components
« Reply #3 on: June 08, 2013, 04:49:09 am »
procedure TBSel.butVacuumClick(Sender: TObject);
begin
  Conn.ExecuteDirect('End Transaction');  // End the transaction started by SQLdb
  Conn.ExecuteDirect('Vacuum');
  Conn.ExecuteDirect('Begin Transaction'); //Start a transaction for SQLdb to use
end;

Please Note:  The above runs without error - i cannot be sure that the 'vacuum' has done whats required.
« Last Edit: June 08, 2013, 04:51:37 am by Pascaluvr »
Windows 7, Lazarus 1.0.8, FPC 2.6.2, SQLite 3

kpeters58

  • Sr. Member
  • ****
  • Posts: 267
SQLite vacuum and SqlDB components
« Reply #4 on: June 18, 2013, 04:03:33 pm »
I just built a very fragmented database and tested your code - it works like a charm!

Thanks,
Kai
« Last Edit: June 18, 2013, 05:50:54 pm by kpeters58 »
Lazarus 2.0.4/FPC 3.0.4/Win 64

 

TinyPortal © 2005-2018