DBI that stands for Database Independent Interface is the standard library for Perl to access Relational Databases (RDBMS) using SQL. It can be used to access any RDBMS using the appropriate Database Driver (DBD).

Many people, instead of directly using DBI, would opt to to use one of the ORMs (Object Relation Mapping) available for Perl. The most popular being DBIx::Class (a.k.a. DBIC) that wraps DBI.

Examples

Simple database access using Perl DBI and SQL

Database Drivers (DBDs)

Generic Database Drivers (DBDs)

  • DBD::ADO for Microsoft ADO (ActiveX Data Objects) (There is also a Win32::ADO module but that's not recommended.)
  • DBD::ODBC to connect to any database via ODBC (Open Database Connectivity)
  • Win32::ODBC solely exist for backwards compatibility. It started life in 1996 when DBD::ODBC didn't exist yet, and Perl on Windows was still a fork that couldn't build CPAN modules (it didn't even support MakeMaker). Use DBD::ODBC instead.

Special Database Drivers

There are all kinds of other Database Drivers that can be used to make data look like they are in a Relational Database.

Not Database Drivers

There are some module in the DBD::* namespace that are not Database drivers.

  • DBD::Log is a logging mechanism for DBI

Wrappers around DBI

  • DBIx::Class (a.k.a. DBIC)
  • Pcore::DBD works on top of the Pcore application framework. It provides general API for:
    • Connections cache for use with forks and threads.
    • Query builder with support of particular db server specific syntax.
    • Schema management (apply / revert changesets).
    • More handy functions for fetching data (from my point of view).

See also the comprehensive list of all the DBD modules.