Click here to get back home

DBI problems

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
DBI problems alx__21 02-11-2008
Get Chitika Premium
Posted by alx__21 on February 11, 2008, 12:11 pm
Please log in for more thread options
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->\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.

Posted by Mark Clements on February 11, 2008, 12:25 pm
Please log in for more thread options
alx__21@hotmail.com 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->\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

Posted by blaine@worldweb.com on February 11, 2008, 12:52 pm
Please log in for more thread options
On Feb 11, 10:25 am, Mark Clements
> alx_...@hotmail.com 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->\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.



Posted by alx__21 on February 11, 2008, 12:53 pm
Please log in for more thread options
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.

Posted by alx__21 on February 11, 2008, 1:58 pm
Please log in for more thread options
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.

Similar ThreadsPosted
LWP problems July 11, 2005, 8:04 pm
LWP-problems December 13, 2005, 2:14 am
help me problems cgi January 14, 2007, 9:42 am
Problems with PAR December 15, 2007, 7:59 am
Problems with proxy .. August 15, 2004, 1:50 pm
Problems with using Autoloader November 15, 2004, 1:17 am
CRAXDDRT problems January 20, 2005, 9:00 am
Redirect problems... January 26, 2005, 12:22 pm
DBI - install problems May 20, 2005, 1:18 am
Problems with Gtk::List August 5, 2005, 9:37 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap