sqlite in perl and php

geoff on 2004-10-25T08:13:03

so I'm trying to use both DBD::SQLite and php (5.0.2) to access the same sqlite database. depending on who creates the database file I get

file is encrypted or is not a database


errors - in php if I use perl to create the file and perl if I use php. some initial googling seems to think that it's because the two libaries are using different sqlite versions, but I'm not entirely sure.



please tell me that someone has seen this before and there is an obvious fix to the compatibility issues.


Different SQLite versions?

bart on 2004-10-25T09:56:39

That sounds like a probably reason. SQLite 2.x and 3.x are not compatible qua databasefile.

I don't know what version of SQLite PHP 5 is using, but checking for Perl is quite easy, according to the changes file, DBD::SQLite started using SQLite 3 starting with DBD::SQLite version 1.00. So, whatever version it is you have, try installing the latest one of the other generation.

I wish Perl had a better way to have different generations of modules live together, but I think the best you can do in order not to mess the existing installation up, is install the other version in a separate libroot, and use lib to make Perl load that one in your script. Due to the way DBI works, this will happen at run time, when you connect() to the database.

Re:Different SQLite versions?

atcroft on 2004-10-25T11:56:33

And thus the reason for DBD::SQLite2. From the README for DBD::SQLite2,

Note: DBD::SQLite2 is the old version of DBD::SQLite, and embeds version 2.x.x of the sqlite library. The current version of DBD::SQLite embeds version 3 (or possibly later if I forget to update this file). This release is designed to allow you to have both versions installed on the same system.

Re:Different SQLite versions?

geoff on 2004-10-25T13:28:13

yup, that was it. thanks!

Re:Different SQLite versions?

trachtenberga on 2004-10-25T20:01:36

The SQLite 3.0 thread just occured on php-internals. It'll happen, but not before ApacheCon. :)

-adam

Re:Different SQLite versions?

geoff on 2004-10-29T13:29:25

cool.



while this is neither a php nor perl concern, I was able to put my finger on why this all felt so strange to me this week at nyphp: if versions 2 and 3 databases are not compatible, I would expect that a version 2 client would bomb, however I would expect a version 3 client to say "whoa - you're using a version 2 database." the way it is now, you get this cryptic "file is encrypted" error in both directions, which is very user unfriendly.

Re:Different SQLite versions?

scottj on 2004-11-04T17:26:10

I just came across this same problem today, and this post helped me as well. The error that the SQLite libraries provide is certainly a bit cryptic and not helpful at all. Well, it is helpful when running it through Google, but we really shouldn't have to do that.