I assume that you have AutoCommit => 0 in the connect call, because the following works:
#!/usr/bin/perl use strict; use warnings; use DBI; my $dbh = DBI->connect('dbi:SQLite:test.db', undef, undef, { RaiseError => 1, AutoCommit => 1} ); $dbh->do('VACUUM'); $dbh->disconnect;
You do not need to abandon transactions in order to be able to VACUUM : you can use the following to enable AutoCommit for VACUUM , and after AutoCommit state of AutoCommit to what it was. Add error checking to your taste if you do not install RaiseError .
sub do_vacuum { my ($dbh) = @_; local $dbh->{AutoCommit} = 1; $dbh->do('VACUUM'); return; }
Name it:
do_vacuum($dbh);
source share