[Melbourne-pm] DBI don't start transaction
Toby Corkindale
toby.corkindale at strategicdata.com.au
Mon Jun 8 21:27:08 PDT 2009
scottp at dd.com.au wrote:
> Hey Guys
>
> I have a basic database ($dbh) like this:
>
> my $dbh = DBI->connect("dbi:SQLite:dbname=list.db',"","", {
> RaiseError => 1, AutoCommit => 0 });
>
> I want to do an SQLite attach, which requires no transaction. But DBI
> automatically does a begin on a do or prepare if no begin was run. I can
> reconnect to the database withou AutoCommit => 1, do the attach,
> disconnect, reconnect with AutoCommit => 0, but that is a slow process.
>
> Example of the error:
> $dbh->do('ATTACH DATABASE "/path/to/other.db" as other');
> error = "cannot ATTACH database within transaction(1) at dbdimp.c line
> 403 ..."
>
> Does anyone know how I can do a "do" without a begin if AutoCommit is off?
Would this help?
{
local $dbh->{AutoCommit} = 1;
$dbh->do('ATTACH DATABASE xxx.db');
}
-Toby
More information about the Melbourne-pm
mailing list