DBI problems

Discussion in 'Perl Misc' started by alx__21@hotmail.com, Feb 11, 2008.

  1. Guest

    Hello. Using the following test code:

    #!/usr/bin/perl

    use DBI;

    $db_handle = DBI-
    >connect("dbi:mysql:database=mysql;host=x.x.x.x;user=x;password=x")

    or die "Couldn't connect to database: $DBI::errstr\n";

    //I've edited out some data there obviously

    open(FILEHANDLE, ">", "C:\\test.txt") || die('cannot open file: ' .
    $!);

    $sql = "SELECT * FROM hhdb2.handhelds";
    $statement = $db_handle->prepare($sql)
    or die "Couldn't prepare query '$sql': $DBI::errstr\n";

    $statement->execute()
    or die "Couldn't execute query '$sql': $DBI::errstr\n";
    while ($row_ref = $statement->fetchrow_hashref())
    {
    print FILEHANDLE "$row_ref->{id}\n";
    }

    close(FILEHANDLE);
    $db_handle->dis
    connect();


    .... I get the following error:

    install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC
    contains:
    C:/Perl/site/lib C:/Perl/lib .) at (eval 4) line 3.
    Perhaps the DBD::mysql perl module hasn't been fully installed,
    or perhaps the capitalisation of 'mysql' isn't right.
    Available drivers: DBM, ExampleP, File, Gofer, ODBC, Proxy, SQLite,
    Sponge.
    at Z:\changelist\dbtest2.pl line 5


    I'm sure that DBI is installed (ppm says so) and I've read repeatedly
    that this should be able to use a mysql database. What has gone
    wrong?

    I would appreciate any help.
     
    , Feb 11, 2008
    #1
    1. Advertising

  2. wrote:
    > Hello. Using the following test code:
    >
    > #!/usr/bin/perl
    >
    > use DBI;
    >
    > $db_handle = DBI-
    >> connect("dbi:mysql:database=mysql;host=x.x.x.x;user=x;password=x")

    > or die "Couldn't connect to database: $DBI::errstr\n";
    >
    > //I've edited out some data there obviously
    >
    > open(FILEHANDLE, ">", "C:\\test.txt") || die('cannot open file: ' .
    > $!);
    >
    > $sql = "SELECT * FROM hhdb2.handhelds";
    > $statement = $db_handle->prepare($sql)
    > or die "Couldn't prepare query '$sql': $DBI::errstr\n";
    >
    > $statement->execute()
    > or die "Couldn't execute query '$sql': $DBI::errstr\n";
    > while ($row_ref = $statement->fetchrow_hashref())
    > {
    > print FILEHANDLE "$row_ref->{id}\n";
    > }
    >
    > close(FILEHANDLE);
    > $db_handle->dis
    > connect();
    >
    >
    > ... I get the following error:
    >
    > install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC
    > contains:
    > C:/Perl/site/lib C:/Perl/lib .) at (eval 4) line 3.
    > Perhaps the DBD::mysql perl module hasn't been fully installed,
    > or perhaps the capitalisation of 'mysql' isn't right.
    > Available drivers: DBM, ExampleP, File, Gofer, ODBC, Proxy, SQLite,
    > Sponge.
    > at Z:\changelist\dbtest2.pl line 5
    >
    >
    > I'm sure that DBI is installed (ppm says so) and I've read repeatedly
    > that this should be able to use a mysql database. What has gone
    > wrong?


    You need to install DBD::mysql. Your paths indicate you're on windows so
    I'll assume you're using ActiveState:

    ppm install DBD-mysql

    Mark
     
    Mark Clements, Feb 11, 2008
    #2
    1. Advertising

  3. Guest

    On Feb 11, 10:25 am, Mark Clements
    <> wrote:
    > wrote:
    > > Hello. Using the following test code:

    >
    > > #!/usr/bin/perl

    >
    > > use DBI;

    >
    > > $db_handle = DBI-
    > >> connect("dbi:mysql:database=mysql;host=x.x.x.x;user=x;password=x")

    > > or die "Couldn't connect to database: $DBI::errstr\n";

    >
    > > //I've edited out some data there obviously

    >
    > > open(FILEHANDLE, ">", "C:\\test.txt") || die('cannot open file: ' .
    > > $!);

    >
    > > $sql = "SELECT * FROM hhdb2.handhelds";
    > > $statement = $db_handle->prepare($sql)
    > > or die "Couldn't prepare query '$sql': $DBI::errstr\n";

    >
    > > $statement->execute()
    > > or die "Couldn't execute query '$sql': $DBI::errstr\n";
    > > while ($row_ref = $statement->fetchrow_hashref())
    > > {
    > > print FILEHANDLE "$row_ref->{id}\n";
    > > }

    >
    > > close(FILEHANDLE);
    > > $db_handle->dis
    > > connect();

    >
    > > ... I get the following error:

    >
    > > install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC
    > > contains:
    > > C:/Perl/site/lib C:/Perl/lib .) at (eval 4) line 3.
    > > Perhaps the DBD::mysql perl module hasn't been fully installed,
    > > or perhaps the capitalisation of 'mysql' isn't right.
    > > Available drivers: DBM, ExampleP, File, Gofer, ODBC, Proxy, SQLite,
    > > Sponge.
    > > at Z:\changelist\dbtest2.pl line 5

    >
    > > I'm sure that DBI is installed (ppm says so) and I've read repeatedly
    > > that this should be able to use a mysql database. What has gone
    > > wrong?

    >
    > You need to install DBD::mysql. Your paths indicate you're on windows so
    > I'll assume you're using ActiveState:
    >
    > ppm install DBD-mysql
    >
    > Mark



    If the above command does not work then you will need to use an older
    PPM repository.
    Http://cpan.uwinnipeg.ca/PPMPackages/10xx/package.xml WILL contact the
    package your looking for.
     
    , Feb 11, 2008
    #3
  4. Guest

    This does not appear to exist. I can't find it under the ppm either.
    What does exist is: dbd-mysql-informationschema, dbd-mysql-
    SimpleMySQL, and dbd-mysqlPP. I don't think any of these are what I'm
    looking for.
     
    , Feb 11, 2008
    #4
  5. Guest

    Being kinda new to this it took me a while to figure out what to do
    with your XML file, but now I've got the repository added to ppm and
    the proper file is downloading.

    Thanks Blaine.
     
    , Feb 11, 2008
    #5
    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. ulloa
    Replies:
    1
    Views:
    546
    Juha Laiho
    Jul 22, 2004
  2. culley harrelson

    DBI-PG problems

    culley harrelson, Aug 1, 2003, in forum: Ruby
    Replies:
    5
    Views:
    140
    Michael Garriss
    Aug 1, 2003
  3. Jerome Hauss
    Replies:
    0
    Views:
    185
    Jerome Hauss
    Oct 13, 2004
  4. Asby

    Mason, DBI, and DBI::Pg

    Asby, Jul 24, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    193
  5. Tim Haynes
    Replies:
    3
    Views:
    157
    Ron Reidy
    Sep 13, 2003
Loading...

Share This Page