Ok here is what I get.

Test using DBD::SQLite (same output when used command-line and via webpage)
=====================
the SQLite v3 is 1.27

Test using DBD::SQLite2 (same output when used command-line and via webpage)
the SQLite v2 is 0.33

So definately a difference in sqlite versions. I did a complete example too for you to perhaps test/review.

The v3 example code:
#!/usr/bin/perl -w
use DBD::SQLite;

print "Content-type: text/html\n";
print "Pragma: no-cache\n";
print "Cache-control: no-cache\n";
print "Expires: Mon, 06 May 1970 04:00:00 GMT\n";
print "\n<body>";

$db = DBI->connect("dbi:SQLite:dbname=/tmp/bugpush.db", "", "")
      || die( $DBI::errstr . "\n" );

$db->do("create table xyz (c1 number)");
$db->do("insert into xyz values (100)");

$sth = $db->prepare("select c1 from xyz");
if(! defined($sth) || ! ($sth)) {
  print "Failed to prepare SQL statement:\n";
  print "$DBI::errstr\n";
  exit 1;
}

$rc = $sth->execute();
if (! defined( $rc ) ) {
  print "Unable to execute prepared SQL statement:\n";
  print "$DBI::errstr\n";
  exit 1;
}

while( $href = $sth->fetchrow_hashref ) {
  print $$href{"c1"} . "\n";
}

$sth->finish;
$db->disconnect;

print "</body>";

When run as 'perl file.pl' it successfully outputs the value 100 along with the html tags. But when I access this via mod_perl in a webage I get the "Failed to prepare SQL statement: not an error " error. Note that the /tmp/bugpush.db file gets created but it is zero bytes in size and it is owned by the correct user.

If I remove the /tmp/bugpush.db file and then modify the code to use SQLite2 as so:

#!/usr/bin/perl -w
use DBD::SQLite2;

print "Content-type: text/html\n";
print "Pragma: no-cache\n";
print "Cache-control: no-cache\n";
print "Expires: Mon, 06 May 1970 04:00:00 GMT\n";
print "\n<body>";

$db = DBI->connect("dbi:SQLite2:dbname=/tmp/bugpush.db", "", "")
      || die( $DBI::errstr . "\n" );

$db->do("create table xyz (c1 number)");
$db->do("insert into xyz values (100)");

$sth = $db->prepare("select c1 from xyz");
if(! defined($sth) || ! ($sth)) {
  print "Failed to prepare SQL statement:\n";
  print "$DBI::errstr\n";
  exit 1;
}

$rc = $sth->execute();
if (! defined( $rc ) ) {
  print "Unable to execute prepared SQL statement:\n";
  print "$DBI::errstr\n";
  exit 1;
}

while( $href = $sth->fetchrow_hashref ) {
  print $$href{"c1"} . "\n";
}

$sth->finish;
$db->disconnect;

print "</body>";

The command-line test again returns 100 but also when accessed via mod_perl I see it prints 100 as well.

Can you perhaps test this on your end?


On 12/1/2009 6:42 PM, Darren Duncan wrote:
Darren Duncan wrote:
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 mod_perl:

  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;

Correction, you need to add a $ sigil like this:

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

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

-- Darren Duncan

--

Mike Campbell | Principal Support Engineer | 407.458.2313
Oracle Support Services
7453 TG Lee Blvd. | Orlando, FL 32822
_______________________________________________
DBD-SQLite mailing list
DBD-SQLite@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbd-sqlite

Reply via email to