use DBI;
$dbh = DBI->connect("dbi:SQLite:dbname=mydb.db","","", {AutoCommit=>0, 
RaiseError=>1, ShowErrorStatement=>1});
eval {$dbh->do("insert into mytable (mycolumn) values ('my data')") };
if ($@) {
    if ($@ =~ m/database is locked/i) {
        print "db is locked\n\n$@";
    } else {
        print $@;
    }
}
# bound to be some errors, but you get the idea :-)

Maybe other Perl guys here have a better solution, but I don't think DBI sets 
or returns an error code specific to "locked".  So far, my stuff hasn't been 
busy enough with writes to generate locked DB errors, so I haven't had to deal 
with it.

Have a look at http://search.cpan.org/src/TIMB/DBI_AdvancedTalk_2004/index.htm  
Here DBI's author talks about a variety of topics including error handling.  
It's beem a good reference for me.

 -Clark


----- Original Message ----
From: Sripathi Raj <[EMAIL PROTECTED]>
To: [email protected]
Sent: Monday, March 20, 2006 2:34:06 PM
Subject: [sqlite] SQLite Busy status from DBD::SQLite

Hi,

 I'm using DBD::SQlite with Perl. How do I know that the execution of a
statement failed because the database was locked? Should I examine the
$DBI::errstr? Does DBI set an error code or something?

Thanks,

Raj



Reply via email to