Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

replacement for DBI?

by jck (Scribe)
on Oct 01, 2020 at 23:41 UTC ( #11122444=perlquestion: print w/replies, xml ) Need Help??

jck has asked for the wisdom of the Perl Monks concerning the following question:

I have a script that has worked for years, but now it's throwing an error, pointing to the line that attempts to connect to my database.
line 3: use DBI; ... line 20: my $dbh = DBI->connect('DBI:mysql:database_name1;host=localho +st;port=3306', 'username', 'password') or die "Couldn't open database: $DBI::errstr; stopped"; line 22: my $dbh2 = DBI->connect('DBI:mysql:database_name2;host=localh +ost;port=3306', 'username', 'password') or die "Couldn't open database: $DBI::errstr; stopped";

the error message is as follows:

install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /home/domainname/public_html/cgi-bin/ //perl5/lib/perl +5 //perl5/lib/perl5/x86_64-linux-thread-multi //perl/usr/local/lib64/per +l5 //perl/usr/local/share/perl5 //perl/usr/lib64/perl5/vendor_perl //perl/usr/share/perl5/vendor_perl //perl/usr/lib64/perl5 //perl/usr/share/perl5 /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/p +erl5 /usr/share/perl5 .) at (eval 18) 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, Mem, Proxy, SQLite, Spo +nge. at /home/domainname/public_html/cgi-bin/events_db_embed.pl line 20.

should I replace DBI with one of the following? DBM, ExampleP, File, Gofer, Mem, Proxy, SQLite, Sponge.

just as an addendum, I search for DBI as an available module, and it's not listed on my host

Replies are listed 'Best First'.
Re: replacement for DBI?
by NetWallah (Canon) on Oct 02, 2020 at 00:01 UTC
    Did your connection string change ?

    From https://metacpan.org/pod/DBD::mysql, the connection string should be:

    DBI:mysql:database=name2 ...
    Your string appears to use "DBI:mysql:database_name2" (Underscore instead of equals).

                    "Imaginary friends are a sign of a mental disorder if they cause distress, including antisocial behavior. Religion frequently meets that description"

      sorry, I put in "database_name2" as a placeholder. my database name actually does have an underscore in it.
Re: replacement for DBI?
by LanX (Cardinal) on Oct 01, 2020 at 23:58 UTC
    >  Perhaps the DBD::mysql perl module hasn't been fully installed,

    Perhaps the DBD::mysql perl module hasn't been fully installed?

    DBI is just a frontend which provides the API to different backend drivers.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

    PS: could you please edit your post in a way, which doesn't require several pages of width? Like linebreaks in the @INC path?

      sorry - is that better? I just reinstalled DD::mysql, but it's still throwing the same error...

        Reinstalled to where? How?


        The way forward always starts with a minimal test.
Re: replacement for DBI?
by 1nickt (Abbot) on Oct 02, 2020 at 00:21 UTC

    The error message is telling you that the DBI can find drivers for the listed DBs, but not for MySQL. The double slashes in the paths in your @INC look weird. Did you change it, or maybe your shared hosting server did?

    Does your host show DBD::mysql as available?


    The way forward always starts with a minimal test.
      yes, I just checked that DBD::mysql is installed
Re: replacement for DBI?
by Anonymous Monk on Oct 02, 2020 at 00:07 UTC
    "Stop ... don't do anything ... breathe ..." What changed, recently, and exactly when did it change?
      the only thing that I know changed was that I updated our PHP version (we're mostly running off a Wordpress site, with some PERL-scripted add-ons)
        Did you think to put your source-code under source-code control such as git?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11122444]
Approved by LanX
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2020-11-29 23:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?