I am using sqlite with DBI in a perl SMTP system. The program runs until
it gets terminated, currently using CTRL-C but in the future when all runs
fine, using kill of a daemon process.

It appears that when I do an insert in the code, the real insert is
sometimes delayed for quite a while, and is later on combined with
other inserts, as when I do the insert several times, and each time
from an sqlite3 session do a select count(*) on the table, after a number
of inserts without an increase of the count, the count than goes up.

This is not the biggest problem however. If the inserts would only get
delayed and would not get lost if the program is aborted (CTRL-C), that
could be something while far from ideal that I could live with.
The situation however seems to be that inserts are done asynchronously and
sometimes grouped, and may be dropped on CTRL-C.

Is there a way to stop sqlite/dbi from doing inserts asynchronously in
such a way? I tried adding the AutoCommit, but without result.
Or am I simply doing something stupid?


Some relevant pieces of my code:

$self->{"dbh"}=DBI->connect("dbi:SQLite:dbname=$path","","",{ RaiseError
=> 1, AutoCommit => 1 }) || die "Problem with sqlite db at $path";
my $dbh=$self->{"dbh"};
$self->{"add_to_queue"}=$dbh->prepare("INSERT INTO messagequeue
(msgid,fspath,recipient_id,queuename,system_id,person_id,creationtime)
VALUES (?,?,?,?,?,?,?)")or die "Couldn't prepare statement: " .
$dbh->errstr;

..
.

my $sth=$self->{"add_to_queue"};
$sth->execute($id,$file,$recipientid,$queue,$system_id,$person_id,time())
or die "Cannot execute: " . $sth->errstr();

Any pointers on how to get my program to do its inserts reliably and
properly would be very much appreciated.

T.I.A.

Rob

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to