[DBD-SQLite] problems using sqlite with mod_perl in apache

Darren Duncan darren at darrenduncan.net
Wed Dec 2 00:37:30 GMT 2009

Mike Campbell wrote:
> I've done pretty much what you describe earlier today. My database is 
> very small, only a few tables, so I have a sql script that I use to 
> build and rebuild the database tables with.
> I precreate my tables using the command-line sqlite3 or sqlite2 
> executable reading the sql file.
> When I create the tables using sqlite3 and my perl script uses 
> DBD-SQLite-1.27 I get the prepare error when accessing the database from 
> the web interface (but works fine when the script is run as 'perl 
> file.pl'). I then remove the database file and re-create it using 
> sqlite2 and the same sql scripts. In my perl script I use 
> DBD-SQLite2-0.33 and when I access the database using the web interface 
> it all works.
> I suspect that somehow my web server/mod_perl is using a different a 
> different DBD driver somehow. How can I determine what sqlite and/or 
> perl files the webserver is using? Since this is apache on linux I would 
> suspect that it uses the perl modules in /usr/lib/perl5 but perhaps not. 
> If the webserver is using sqlite v2 that would explain the behavior I am 
> seeing but I am at a loss as to how to determine what apache is using.

If the DBI connect string you are using starts with "dbi:SQLite2:dbname=" then 
you are using v2; if it starts with "dbi:SQLite:dbname=" then you are using v3.

As for finding out what version of DBD::SQLite (SQLite 3) you are using, you 
should be able to put code like this in your code either on the shell script or 

   use DBD::SQLite;
   my $version3 = 'the SQLite v3 is ' . DBD::SQLite::VERSION;

Then display or log the value of $version3 where you can see it.

To see what version of DBD::SQLite2 (SQLite 2) you are using, same process but 
for the added '2':

   use DBD::SQLite2;
   my $version2 = 'the SQLite v2 is ' . DBD::SQLite2::VERSION;

Note that DBD::SQLite was SQLite 3 from version 1.0 and later; before version 
1.0 it was SQLite 2.

So, in particular run the above lines under mod_perl and see what you get.  If 
either module isn't installed, the 'use' for it should throw an exception.

-- Darren Duncan

More information about the DBD-SQLite mailing list