donfox1 has asked for the wisdom of the Perl Monks concerning the following question:
I'm using a Perl script to display the contents of a table. On running the script I get a 'Can't locate DBD/mysql.pm in @INC' error. mysql was installed on my mac via homebrew so I'm guessing that's why there is something amiss in my @INC search path?
#!/usr/bin/perl use strict; use warnings; use DBI; my $dbfile = "bank"; my $dsn = "dbi:mysql:dbname=$dbfile"; my $user = "donfox1"; my $password = "nodxof"; my $dbh = DBI->connect($dsn, $user, $password, { PrintError => 0, RaiseError => 1, AutoCommit => 1, FetchHashKeyName => 'NAME_lc', }); my $sql = 'SELECT name, address FROM branch'; my $sth = $dbh->prepare($sql); $sth->execute(1,10); while (my @row = $sth->fetchrow_array) { print "name: $row[0] address: $row[1]\n"; } $sth->execute(12, 17); while (my $row = $sth->fetchrow_hashref) { print "fname: $row->{name} lname: $row->{address}\n"; } $dbh->disconnect; print "\tSTUBB_1\n";
Output on running the script is: ./connect.pl install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (you may need to install the DBD::mysql module) (@INC contains: /Library/Perl/5.18/darwin-thread-multi-2level /Library/Perl/5.18 /Network/Library/Perl/5.18/darwin-thread-multi-2level /Network/Library/Perl/5.18 /Library/Perl/Updates/5.18.2 /System/Library/Perl/5.18/darwin-thread-multi-2level /System/Library/Perl/5.18 /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level /System/Library/Perl/Extras/5.18 .) 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, Proxy, SQLite, Sponge.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Can't locate DBD/mysql.pm in @INC
by AppleFritter (Vicar) on Mar 21, 2015 at 22:54 UTC | |
by donfox1 (Novice) on Mar 22, 2015 at 00:06 UTC | |
Re: Can't locate DBD/mysql.pm in @INC
by sauoq (Abbot) on Mar 22, 2015 at 03:51 UTC | |
by donfox1 (Novice) on Mar 22, 2015 at 15:06 UTC | |
Re: Can't locate DBD/mysql.pm in @INC
by sauoq (Abbot) on Mar 22, 2015 at 03:51 UTC |