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

hell monks , I just installed the DBI module 1.37 , I need to download a good driver module to use it , I am confused , there are so many of them and I am not sure which one to choose or which one should go before the other , I would appricate if someone can tell me which mysql module best for me. thanks a lot.

Replies are listed 'Best First'.
Re: DBI driver
by gmax (Abbot) on May 28, 2003 at 06:00 UTC

    If you plan to use a MySQL database, then the driver is DBD::mysql. It is a XS implementation of the MySQL driver, and it is fast and reliable.

    Alternatively, there is DBD::mysqlPP, a pure perl implementation of the driver, which is slower and not 100% compatible with the former. It is only advisable in cases when you can't install the real stuff (for example, when you don't have the rights to run a C compiler and your admin won't install the driver).

    You may get some more information in the Tutorials section. Reading from a database should be a good start. More useful information at the DBI FAQ

    _ _ _ _ (_|| | |(_|>< _|
Re: DBI driver
by arthas (Hermit) on May 28, 2003 at 10:20 UTC
    Hi Jassica!

    The DBD driver you need depends on the database you are using (DBD::Oracle for Oracle, DBD::mysql for MySql (as you need), ...).

    Some of the databases, like the mySQL which you are writing about, have more that one driver (like gmax already wrote), so you can choose one depending on the features. Anyhow, DBD::mysql is the most common choice.

    Have a look at their pages on CPAN for more information.

    Michele.
Re: DBI driver
by Itatsumaki (Friar) on May 28, 2003 at 15:56 UTC

    As others have noted, you choose your driver based on the database you wish to access. As best as I know DBI = DB I(nterface) and DBD = DB D(river). The driver for each database is wrapped up into a separate module named for the database, e.g. DBD::Oracle, DBD::MySQL, DBD::CSV, etc.

    But others said all that. I wanted to point out that there are some databases that do not have drivers (MS-SQL, MS-Access). However, even in those cases you can use DBI by using the handy-dandy super-useful ODBC driver. ODBC (Open DB Connectivity, I think) allows you to access most databases via a common protocol. It is generally slower to access a database through DBD::ODBC than it is through the generic driver, _but_ code written DBD::ODBC can be highly cross-DB portable. Further, there are those cases where you _must_ use DBD::ODBC because no generic driver exists. If you are on a *NIX system, then ODBC set-up isn't trivial, but isn't back-breaking either. If you are in a WinXX system then ODBC setup is trivial.

    -Tats