>So, I want all the perl modules to be loaded when Apache2 starts, and
>then a $dbh created for each user when the user comes to the web site,
>but not recreated for the same user on every reload. I am assuming
>that would be the correct way to work speedily.

I had the same problem, and it's a huge pain, even when you have root privilege.

I never did completely solve it.  I had some success with explicit 
$dbh->disconnect calls before the script exits, but I could never prove why it 
worked.  Ultimately, I abandoned mod_perl.  Having to restart Apache every time 
I update code in a module was a big obstacle.

I always thought having a single $dbh across all instances (open it in an init 
script that runs when Apache starts, and never close it) might be the correct 
approach.

Near as I can tell, the alternative is to have a per-request connection.  To 
get 
this with mod_perl, you have to define and export $dbh in a module.  Though I 
never retrofotted it back into the app I was running under mod_perl, it got me 
in the habit of writing an app-specific init.pm where I could define truly 
transient request-global variables.  Then I just use the init module in every 
script in the app.

 -Clark



----- Original Message ----
From: P Kishor <punk.k...@gmail.com>
To: General Discussion of SQLite Database <sqlite-users@sqlite.org>
Sent: Fri, October 8, 2010 11:49:43 PM
Subject: [sqlite] using SQLite with mod_perl

This is a perl question really, so apologies to the SQLite community.
However, I am stuck, and I am flailing on various forums
(perlmonks/stackoverflow), hoping to strike lucky. My problem is that
I am running into the "database locked" error under mod_perl with
Apache2. I thought I had surmounted this problem, but it is back with
a vengeance.

Here is what is going on in a single web action --

    SELECT col1 FROM table WHERE condition;
    if (col1 exists) {
        UPDATE table SET col2 = <new value>
    }

Well, I get the "db is locked" error at the UPDATE statement. Now, in
my httpd.conf I started using

    PerlModule Apache::DBI

and I thought my troubles were over. Except, this lock problem has
started rearing up again. I have tried a few other things, such as
starting every db action with `$dbh->begin_work` and ending with
`$dbh->commit`, but I am already using `AutoCommit => 1` so I am not
sure if that even has any effect.

My application is being loaded in Apache conf file with

    <Location />
        SetHandler perl-script
        PerlHandler Plack::Handler::Apache2
        PerlSetVar psgi_app /path/to/application.pl
    </Location>

So, I want all the perl modules to be loaded when Apache2 starts, and
then a $dbh created for each user when the user comes to the web site,
but not recreated for the same user on every reload. I am assuming
that would be the correct way to work speedily.

Perhaps SQLite is the wrong tool to use with mod_perl (or any
persistent web environment), but I want to establish that for sure
before trying some other db.

Any ideas?

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

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

Reply via email to