1 message in com.mysql.lists.perlRE: Help Needed with DBD:mysql module...| From | Sent On | Attachments |
|---|---|---|
| Ghulam A. Farrukh | 20 Apr 2002 22:10 |
| Subject: | RE: Help Needed with DBD:mysql module (Worked)![]() |
|---|---|
| From: | Ghulam A. Farrukh (gafa...@yahoo.com) |
| Date: | 04/20/2002 10:10:38 PM |
| List: | com.mysql.lists.perl |
David,
Thanks much. It worked perfectly. Actually, I was connecting OK, but was not "fetching" values properly. Thanks again for your time and effort.
-- Ghulam A. Farrukh
--- David Kirol <d.ki...@attbi.com> wrote:
Ghulam, I hit the send button too soon. After connecting $dbh is a database handle object and if you try to print it you get the dbi::db=HASH(.....) response you saw. The way to use this handle is documented in the DBI docs. Try this: After you connect and you will know you have connected if you use:
$dbh = DBI->connect($mscs, $dbuser, $dbpw) or die "Connect fails to $dbname\nError = ", $DBI::errstr;
and the script continues past this statment. Add:
my @tables = $dbh->tables; foreach (@tables) { print"$_\n"; }
This will print a list of tables which the user connected to the database 'owns'.
HTH
-----Original Message----- From: Ghulam A. Farrukh [mailto:gafa...@yahoo.com] Sent: Saturday, April 20, 2002 4:35 AM To: Msql...@lists.mysql.com Subject: Help Needed with DBD:mysql module
Hi,
Please help. I am having difficulty connecting to mysql through Perl. The DBI is connected and mysql is listed as one of the databases for which it has a driver. However, it cannot find any data sources.
Thanks.
-- GAF
Platform: Intel running Linux Red Hat 6.0 MySQL: 3.22... Perl: 5.005-3
The following script runs correctly, identifying the presence of mysql database.
use strict; use DBI;
print "Here's the list of DBI drivers:\n";
my @available_drivers = DBI->available_drivers('quite'); my $driver;
foreach $driver (@available_drivers) { print "$driver\n"; }
Upon running this, the following output is produced.
Here's a list of DBI drivers: ADO ExampleP Multiplex Proxy mysql
However, when I run the following to connect to the database, I am not able to connect (mysqld is running and works perfectly at prompt or with PhP).
my $dsn = 'dbi:mysql:test:localhost:3306';
my $dbh = DBI->connect($dsn, "myUser", "myPass");
print "dbh is $dbh\n";
==> This prints something like this
dbi::db=HASH(.....)
Note that mysql is missing from up there. Thanks so much.
__________________________________________________ Do You Yahoo!? Yahoo! Games - play chess, backgammon, pool and more http://games.yahoo.com/
---------------------------------------------------------------------
Please check
"http://www.mysql.com/Manual_chapter/manual_toc.html"
before posting. To request this thread, e-mail msql...@lists.mysql.com
To unsubscribe, send a message to the address shown in the List-Unsubscribe header of this message. If you cannot see it, e-mail msql...@lists.mysql.com instead.
__________________________________________________ Do You Yahoo!? Yahoo! Games - play chess, backgammon, pool and more http://games.yahoo.com/




