mysql load data infile error from inside a perl program

Discussion in 'Perl Misc' started by Balldrew J. Bag, Jul 25, 2003.

  1. 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.
    Balldrew J. Bag, Jul 25, 2003
    #1
    1. Advertising

  2. In article <IbiUa.1646$>,
    "Balldrew J. Bag" <> wrote:

    > 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...

    --
    Michael Budash
    Michael Budash, Jul 26, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. las

    infile.get(x)

    las, Jul 30, 2003, in forum: C++
    Replies:
    7
    Views:
    3,695
    Greg Comeau
    Jul 30, 2003
  2. Alex Vinokur

    infile.rdbuf() for empty file

    Alex Vinokur, Feb 2, 2005, in forum: C++
    Replies:
    5
    Views:
    779
    Dietmar Kuehl
    Feb 3, 2005
  3. questioner
    Replies:
    1
    Views:
    363
    A. Lloyd Flanagan
    May 14, 2004
  4. waltbrad

    "inFile" object cannot read EOF

    waltbrad, Jun 7, 2007, in forum: C++
    Replies:
    15
    Views:
    614
    Jerry Coffin
    Jun 11, 2007
  5. Replies:
    2
    Views:
    373
    Dennis Lee Bieber
    Jun 10, 2007
Loading...

Share This Page