Matt Fenwick
Matt Fenwick

Reputation: 49105

Verify presence of MySQL driver

I have a perl application that uses a MySQL backend.

How do I verify that the MySQL and database drivers are accessible?

I'm currently doing the following, but I don't know if it is actually a sufficient test -- I'd hate to find out six months down the line that I'm not doing the right test:

use Test::More;

BEGIN { use_ok('DBI'); }
BEGIN { use_ok('DBD::mysql'); }

done_testing();

Upvotes: 2

Views: 123

Answers (2)

Alexandr Ciornii
Alexandr Ciornii

Reputation: 7392

This is enough to check that connection will be available from Perl side. If you want to check if mysql server is available, you need to connect to it.

P.S. You can also add version checking for DBD::mysql. For ex. 4.001 fixes serious bug in utf8 support.

Upvotes: 2

ciderpunx
ciderpunx

Reputation: 1

Well, it looks fine to me, but if you want to be sure, you can check for the presence of the actual filepaths in your %INC ie:

perl -MDBI -e 'die unless $INC{"DBI.pm"}'
perl -MDBD::mysql -e 'die unless $INC{"DBD/mysql.pm"}'

Upvotes: 0

Related Questions