mysql load data infile error from inside a perl program

B

Balldrew J. Bag

This is my first attempt at writing something with Perl, so this is
beyond a newbie question.

I'm both creating a table and trying to use the load data infile command
from within a perl program. All the permissions are set right and it
actually does create the table and load the data, but it gives the
following error and dies:

DBD::mysql::st execute failed: Access denied for user:
'hightone@localhost' (Using password: YES) at
/usr/lib/perl5/site_perl/5.6.0/i386-linux/Mysql.pm line 172.
count: Mysql::Statement=HASH(0x8246d4c)

That second line is me trying to output a variable called count's
contents. It should be an integer since this is what I'm doing:

$count = $db->query("select count(notes) from $noteList");

The fact that it prints something weird might be a clue.
 
M

Michael Budash

Balldrew J. Bag said:
This is my first attempt at writing something with Perl, so this is
beyond a newbie question.

I'm both creating a table and trying to use the load data infile command
from within a perl program. All the permissions are set right and it
actually does create the table and load the data, but it gives the
following error and dies:

DBD::mysql::st execute failed: Access denied for user:
'hightone@localhost' (Using password: YES) at
/usr/lib/perl5/site_perl/5.6.0/i386-linux/Mysql.pm line 172.

looks like your login (userid and/or password) is incorrect to me...
count: Mysql::Statement=HASH(0x8246d4c)

That second line is me trying to output a variable called count's
contents. It should be an integer since this is what I'm doing:

$count = $db->query("select count(notes) from $noteList");

The fact that it prints something weird might be a clue.

nope - per the Mysql.pm docs, its 'query' method doesn't return what you
think it does - it returns:

...a statement handle which lets you further explore
what the server has to tell you. On error the return
value is undef.

this would work likely for you:

my $sth = $db->query("select count(notes) from $noteList") or die
("Can't get statement handle: " . $db->errmsg);

my @arr = $sth->fetchrow or die ("Can't retrieve row: " . $db->errmsg);

$count = $arr[0];

hope this helps...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top