Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > trying to connect to a mysql database, to input a file

Reply
Thread Tools

trying to connect to a mysql database, to input a file

 
 
ewitkop90@hotmail.com
Guest
Posts: n/a
 
      01-08-2005
This is my code:
__________________________________________________ ________________
#!/usr/bin/perl -w
#insert data into mysql
use DBI;

$dbh = DBI->connect('DBI:mysql;firewall:localhost:3306','xxxx ',
'xxxxxxx',
{RaiseError => 1, AutoCommit => 1 })


$dbh->do("LOAD DATA INFILE '/var/log/firewall/ns-complete' INTO TABLE
firewall FIELDS TERMINATED BY '
,' LINES TERMINATED BY '\n'");

$dbh->disconnect;
#EOF
__________________________________________________ _______________
But it is not working. It is giving me the following error:

Scalar found where operator expected at ./mysql-fwlog-input line 9,
near ")


$dbh"
(Missing semicolon on previous line?)
syntax error at ./mysql-fwlog-input line 9, near ")


$dbh"
Execution of ./mysql-fwlog-input aborted due to compilation errors.

Can someone point out what is wrong. According to my docs, this is the
right syntax.

 
Reply With Quote
 
 
 
 
ewitkop90@hotmail.com
Guest
Posts: n/a
 
      01-08-2005
Also I forgot to mention that line 9 is the dbh->do string. The actual
sql command where I input the file is crapping out.

 
Reply With Quote
 
 
 
 
Martin Kissner
Guest
Posts: n/a
 
      01-08-2005
wrote :

> (Missing semicolon on previous line?)
> syntax error at ./mysql-fwlog-input line 9, near ")

why don't just follow the request?

...
{RaiseError => 1, AutoCommit => 1 });
$dbh->do("LOAD DATA INFILE ...

--
Epur Si Muove (Gallileo Gallilei)
 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      01-09-2005
<> wrote:


> (Missing semicolon on previous line?)
> syntax error at ./mysql-fwlog-input line 9, near ")



Did you read the message?

Did you do what the message said to do?

The parser itself told you how to fix the problem, but you
have to listen to what it says for that to help.

Sheesh!


> According to my docs, this is the
> right syntax.



That is a silly thing to say when you get a syntax error. The
parser that is emitting the message is *the definition* of
the right syntax.

If it says you have a syntax error, then you have a syntax error
(or a bug in the parser which is not likely to go unnoticed long).


--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Peter Wyzl
Guest
Posts: n/a
 
      01-09-2005
<> wrote in message
news: ups.com...
: This is my code:

This would be the 'previous line missing the semicolon'

: $dbh = DBI->connect('DBI:mysql;firewall:localhost:3306','xxxx ',
: 'xxxxxxx',
: {RaiseError => 1, AutoCommit => 1 })


This would be the syntax error telling you how to fix it...

: (Missing semicolon on previous line?)
: syntax error at ./mysql-fwlog-input line 9, near ")

Missing a semicolon on the previous line....?

P
--
http://cgi.ebay.com.au/ws/eBayISAPI....tem=4516341671
print "Just another Perl Hacker";



 
Reply With Quote
 
erik
Guest
Posts: n/a
 
      01-09-2005

Peter Wyzl wrote:
> <> wrote in message
> news: ups.com...
> : This is my code:
>
> This would be the 'previous line missing the semicolon'
>
> : $dbh = DBI->connect('DBI:mysql;firewall:localhost:3306','xxxx ',
> : 'xxxxxxx',
> : {RaiseError => 1, AutoCommit => 1 })
>
>
> This would be the syntax error telling you how to fix it...
>
> : (Missing semicolon on previous line?)
> : syntax error at ./mysql-fwlog-input line 9, near ")
>
> Missing a semicolon on the previous line....?
>
> P
> --
> http://cgi.ebay.com.au/ws/eBayISAPI....tem=4516341671
> print "Just another Perl Hacker";



I did trying different syntaxes before posting to the group. What ever
I changed, was not working. Give me a little credit.

Thanks all.

 
Reply With Quote
 
erik
Guest
Posts: n/a
 
      01-09-2005

Peter Wyzl wrote:
> <> wrote in message
> news: ups.com...
> : This is my code:
>
> This would be the 'previous line missing the semicolon'
>
> : $dbh = DBI->connect('DBI:mysql;firewall:localhost:3306','xxxx ',
> : 'xxxxxxx',
> : {RaiseError => 1, AutoCommit => 1 })
>
>
> This would be the syntax error telling you how to fix it...
>
> : (Missing semicolon on previous line?)
> : syntax error at ./mysql-fwlog-input line 9, near ")
>
> Missing a semicolon on the previous line....?
>
> P
> --
> http://cgi.ebay.com.au/ws/eBayISAPI....tem=4516341671
> print "Just another Perl Hacker";



I did try different syntaxes before posting to the group. What ever I
changed, was not working. Give me a little credit.

Thanks all.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to connect to a mySQL database and get... Plagued Software 0 06-07-2007 09:14 PM
Getting "SQLException: No suitable driver" when trying to connect to mysql from eclipse jborup Java 2 02-04-2007 04:44 PM
Getting "SQLException: No suitable driver" when trying to connect to mysql from eclipse jborup Java 1 02-03-2007 01:36 PM
Aliant TV - Trying to connect a wireless router, not able to connect to Internet rich irving Computer Support 5 01-11-2006 06:30 PM
Seen this message? Can't connect to local MySQL server through socket '/tmp/mysql.sock' Allen Marshall Perl Misc 1 01-24-2004 10:55 PM



Advertisments