CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: DBI:
Error: file is encrypted or is not a database

 



frznchckn2
New User

Dec 28, 2010, 4:27 PM

Post #1 of 5 (4567 views)
Error: file is encrypted or is not a database Can't Post

I created a database and inserted some data using the Perl DBD module. However, when I try to read the data via sqlite3 I received the following message:

Error: file is encrypted or is not a database

This only happens when I try to write information using the perl module. I'm able to insert information using sqlite3 and then read it via perl but not vice versa.


FishMonger
Veteran / Moderator

Dec 28, 2010, 4:53 PM

Post #2 of 5 (4564 views)
Re: [frznchckn2] Error: file is encrypted or is not a database [In reply to] Can't Post

First you say that you receive the error when you read the data via sqlite3 then you say it only happens when you try to write information using the perl module. Which is it?

If you're having a problem with your Perl script, we can help, but if you're having a problem with command line sqlite calls, then an sqlite forum would be a better place to post your question.

If you need help with your Perl script, then you'll need to post the script and a clear question on the part that is giving you trouble.


frznchckn2
New User

Dec 28, 2010, 7:46 PM

Post #3 of 5 (4560 views)
Re: [FishMonger] Error: file is encrypted or is not a database [In reply to] Can't Post

For clarification: If I create a database and populate with sqlite3 I can read the database using perl or sqlite3.

If I create a database and populate with perl DBD module, I can only read the data using perl and attempting to access the data via sqlite3 yields the error I described.


Code
 #!/usr/bin/perl 

use DBI qw(:sql_types);

my $dbfile = "tmp.db";

my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","","");



$sth = $dbh->prepare("CREATE TABLE logicFcns (logicFcnsKey INTEGER PRIMARY KEY, fcn TEXT)") or die $dbh->errstr;
$sth->execute() or die $dbh->errstr;
$sth = $dbh->prepare("insert into logicFcns (fcn) values ('and_a_b')");
$sth->execute();

$sth = $dbh->prepare("SELECT * FROM logicFcns");
$sth->execute();
my $row = $sth->fetch;
my $blobo = $row->[1];

print "$row\n";
print "$blobo\n";


$sth->finish;
$rc = $dbh->disconnect or warn $dbh->errstr;



FishMonger
Veteran / Moderator

Dec 29, 2010, 6:52 AM

Post #4 of 5 (4553 views)
Re: [frznchckn2] Error: file is encrypted or is not a database [In reply to] Can't Post

Other than the missing warnings and strict pragmas, I don't see any real issues with the script and nothing that would account for your issue.

I haven't used sqlite (I use mysql) so I can't help on that side of the issue.

My best recommendation is to send an email to the author/maintainer of the DBD module, or submit a bug report.
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBD-SQLite

What method did you use to initially create the database?

I assume you used sqlite3 tools to create the db. Try going the other way around. Create and populate the db in the Perl script, then after the script exits, see if you can read and update the db using sqlite commands.


frznchckn2
New User

Dec 29, 2010, 7:57 AM

Post #5 of 5 (4549 views)
Re: [FishMonger] Error: file is encrypted or is not a database [In reply to] Can't Post

Thank you, I went to submit a bug and noticed in the form that DBD-SQLite goes up to verision 1.31 while I was using 0.31.

The vast differences between these two versions include using a different version of the SQLite database format.

Updating to 1.31 solved my problem.

Thanks.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives