Apache DBD API

The Proposed Apache DBD Framework serves to enable database applications to work efficiently within Apache 2.1 and higher. It eases development and provides optimised cross-database, cross-MPM support for free.

This page is a bare-bones description of the API. Detailed code- level documentation is included in apr_dbd.h and in the mod_dbd page.

Figure 1

The DBD API decouples database support from applications. Instead of having an Authentication or Logging module for each of many databases, a single Authentication and a single Logging module will work with any database. Applications such as a Namespace module (mod_sql) or a scripting module such as those for Perl, PHP, and Python, can also benefit.

The APR deals with the DBD API itself and multiple backends, while mod_dbd is a thin frontend module to deal with the Apache data structures and provide an efficient implementation with both threaded and non-threaded MPMs.

System Components

The components currently available are:


The apr_dbd framework presents a common API for different SQL database engines. The API is documented in apr_dbd.h.

DBD Drivers

APR DBD Drivers are currently available for PostgreSQL and SQLite within SVN. The apr_dbd architecture supports dynamic loading of database driver modules, so that new drivers can be installed at any time, without any requirement to recompile APR (provided the platform supports dynamic loading).

A MySQL driver is available separately. The reason MySQL is not included is because it is licensed under the GPL, which is not compatible with Apache policy. This is not a problem for third-parties such as the developer (WebÞing) or a Linux distributor.


mod_dbd presents the API for Apache modules, and deals with managing database connections efficiently for both threaded and non-threaded MPMs.


mod_sql is an XML Namespace Module that builds on mod_dbd to implement SQL handling in XML applications with mod_publisher or mod_xmlns. mod_sql is not part of the DBD framework, but is the first application to use it.


apr_dbd and mod_dbd are now in current SVN and Apache 2.2 releases.

Other related software is available from apache.webthing.com.


DBD Authentication (mod_authn_dbd) is included in Apache 2.2. DBD Authorisation (mod_authz_dbd) is available in /trunk/, but not in the release version 2.2, because it was too new and untested when 2.2.0 was released.

However, the trunk version is not compatible with 2.2, for reasons unconnected with DBD. So here's a version that works with 2.2.x releases. You'll need both mod_authz_dbd.c and mod_authz_dbd.h. You can then compile it using apxs, load it with LoadModule, and then take advantage of SQL-based authorization and login (mod_authz_dbd).