Reputation: 1075
I have always successfully used Perl with SQLite, using DBI
and DBD::SQLite
.
Recently I installed a MySQL client and server on my Ubuntu system, as well as DBD::mysql
. MySQL works fine, but after installing the Perl module I ran a different project on SQLite and I got the message that there was no DBD::SQLite
.
I reinstalled DBD::SQLite
using CPAN and now the databases that I created seem no longer to be valid files. If I create a very simple database like this
my $dbh = DBI->connect("dbi:SQLite:dbname=test.db","","") or die $DBI::errstr;
my $sth = $dbh->prepare("CREATE TABLE test (id INTEGER, name char(100), PRIMARY KEY (id))");
$sth->execute();
$sth->finish;
$dbh->disconnect();
and then try to open this file using SQLiteStudio I get the message
Error while opening test.db: file is encrypted or is not a database
In the Linux console the following message appears
file is encrypted or is not a database
while executing
"sqlite2 $name $_path"
(object "::sqlite20" method "::Sqlite2::createDbObject" body line 2)
invoked from within
"createDbObject ::database$dbNum"
So apparently installing DBD::mysql
screwed with DBD:SQLite
.
Does anyone have any ideas on why this happened and how to fix it?
Upvotes: 0
Views: 185
Reputation: 386361
Since version 1.00 in 2004, DBD::SQLite comes with SQLite 3 and thus creates and manipulates SQLite 3 databases. You're using tools that create and manipulate SQLite 2 databases. They are not compatible.
The format used by SQLite database files has been completely revised. The old version 2.1 format and the new 3.0 format are incompatible with one another. Version 2.8 of SQLite will not read a version 3.0 database files and version 3.0 of SQLite will not read a version 2.8 database file.
Quoted from SQLite documentation written when SQLite 3 came out.
Downgrade DBD::SQLite to a version earlier than 1.00 or use sqlite3
instead of sqlite2
.
Upvotes: 1