The Perl DBI


MySQL connectivity from Perl is handled in the same way that you can communicate with many other types of database: using the Perl Database Interface, or DBI.

If you have already used DBI with another database, you already know the essentials and will find it very easy to interface with MySQL.

DBI is independent of the database back ends and uses a specific database driver module, known as DBD, to interface with each DBMS.

If you do not already have DBI installed, use cpan to download and install it, as follows. You should either run this command as the root user on your system or have your system administrator run it for you.

 # cpan cpan> install DBI 


The installation process produces a lot of output as it downloads and installs DBI and any other modules that it is dependent upon.

CPAN

The Comprehensive Perl Archive Network (CPAN) is a large collection of Perl software and documentation. The cpan utility is used to automatically download and install packages from this resource.


You also need to install a database driver for MySQL, which is called DBD::mysql. Enter this command at the cpan> prompt:

 cpan> install DBD::mysql 


On Windows systems using the ActivePerl distribution, use the ppm.bat script to install Perl modules, as follows:

 C:\perl\bin> ppm.bat ppm> install DBI ... ppm> install dbd::mysql 





Sams Teach Yourself MySQL in 10 Minutes
Sams Teach Yourself MySQL in 10 Minutes
ISBN: 0672328631
EAN: 2147483647
Year: 2006
Pages: 165
Authors: Chris Newman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net