473,473 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Unable to run sql statements in perl

33 New Member
Hi All,
I am newbie in Perl Scripting. I have a requirement where I need to execute sql file on an Sqlite database.
sqlite database has been set with password.
I could connect to database. But when I try to execute sql statements its giving as "DBD::SQLite::db prepare failed: file is encrypted or is not a database at <SQL> line 1." Here is my code

Expand|Select|Wrap|Line Numbers
  1. use DBI;
  2.  
  3. my $dbfile = '../myData.db';      # your database file
  4. my $dbh = DBI->connect(          # connect to your database, create if needed
  5.     "dbi:SQLite:dbname=$dbfile", # DSN: dbi, driver, database file
  6.     "",                          # no user
  7.     "xxxxxxxxxxxxxxxxxxxx",  #password
  8.     { RaiseError => 1 },         # complain if something goes wrong
  9. ) or die $DBI::errstr;
  10.  
  11. open SQL, "<../myDB.sql" or die $!;
  12. while(<SQL>)
  13. {
  14.     ($dbh->prepare($_))->execute();
  15. }
  16. close SQL;
  17.  
I created that db in Lita(SqLite Administration Tool)and have set the password.
I am running the perl scripts on Windows XP using ActivePerl version 5.12.2.
Oct 31 '11 #1
1 1727
chorny
80 Recognized Expert New Member
Is every SQL statement on it's own line? I mean 1:1 relationship statement:line.
Nov 11 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

58
by: @ | last post by:
A benchmark in 2002 showed PHP is much slower in shell or when Apache has Mod_Perl. With the new PHP kissing Java's ass, Perl is once again the #1 CGI choice. Java is for a big team in short...
52
by: Olivier Scalbert | last post by:
Hello , What is the python way of doing this : perl -pi -e 's/string1/string2/' file ? Thanks Olivier
3
by: lonelyplanet999 | last post by:
Hi, I'm a newbie to perl and is now studying about perl programming, I read some perl programming tutorials online (enter 'Perl tutorial' at google.com) and also find some sample perl scripts...
0
by: josh | last post by:
Hey All, Thanks Dino for your previous help. I have a working Perl script on a Linux box using a soap::lite wrapper. I am trying to use the Perl module WSDL::generator to generate a WSDL. ...
9
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at...
12
by: jonathan184 | last post by:
Hi the purpose of the script I am trying to do is to access a dir and run the ls -l command which will show the files and the modified date, no w the script is to check two files in that dir , if the...
4
by: jonathan184 | last post by:
Hi I have a perl script, basically what it is suppose to do is check a folder with files. Now the files are checked using a timestamp with the command ls -l so the timestamp in this format is...
1
by: srikantvm | last post by:
Hi All, I am using perl, v5.8.8 built for MSWin32-x86-multi-thread and i tried installing the DBD-Oracle module but unable to install. Please find below the steps followed by me: 1) I first...
3
by: melbourno | last post by:
I have a Perl script that I run and the out come as showing below: Log chain 1: Reading: server 2\08120700.mls Reading: server 2\08120900.mls Reading: server 1\08121100.mls Log chain 2: ...
1
by: swetna | last post by:
Hi, I am getting the following error when i try to run the perl code syntax error at new.pl line 26, near ") ## Call functions ## while" syntax error at new.pl line 32, near "}"...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.