sweet idleness

sqlite and "closing dbh with active statement handles"

April 18, 2008

and NO! I did not forget to call finish. 

#!/usr/bin/perl
use DBI;
use strict;
use warnings;

my $dbh = DBI->connect("dbi:SQLite:database=admin.db","","",
      { AutoCommit => 1,
        RaiseError => 1})  or die $DBI::errstr;

my $sth=$dbh->prepare(’select * from id_generator’) ;
$sth->execute();
while (my @row = $sth->fetchrow_array()){

}
$sth->finish;
$dbh->disconnect;

Maybe I mispelled finish.

Maybe it’s just a glitch and the warning will be gone the next time I run it.

Maybe I should run it again.

One more time. 

Is finish spelled with 1 ‘n’?

I will run it again, but this time I will say parts of "Our Father" before I run it (…lead us not into tempation but deliver us from evil. Amen).

They say Mary is kinder than the Big Guy, maybe I should ask her for help. 

There were no computers during her time, I don’t think she would know the answer.

Or I can just ask her to ask Him to help me. So very Wedding at Canaan!

Are there computers where God is? Aaahh! Oh yeah, Mr Omnipresent. 

Maybe I should just ask for something else.

Lord,

    Won’t you give me 5 million pesos. Forget the sqlite problem I was asking earlier. I will just ask Google.

In J’s name. Amen. 

 

I got the answer after a few minutes with Google.

http://www.perlmonks.org/?node_id=665714

Currently DBD::SQLite can finalize statements only via DESTROY method. In simplest case you can always use "undef $sth" or wait untill it goes out of scope which will finalize statement.

 

Posted by george at 4:19 pm | permalink

Previous Comments

Thanks for posting this - it helped

Posted by Anonymous Coward at June 15, 2008, 6:32 am

Cheers dude, this helped me find that perlmonks article. Thought you’d appreciate a thank you :)

Posted by James Aitken at July 1, 2008, 9:24 pm

Thought you’d appreciate a thank you!

Posted by ClubPenguin at April 18, 2011, 9:32 am

Thanks for taking this opportunity to discuss this, I feel fervently about this and I like learning about this subject.

Posted by Coach Outlet Canada at April 23, 2011, 3:07 pm