Driver Manager

The adbc_driver_manager package provides a driver manager interface for Python. The package provides two APIs:

  1. Low-level bindings that are essentially the same as the C API.

  2. If PyArrow or Polars are installed, a DBAPI (PEP 249) compliant interface.

Installation

pip install adbc_driver_manager

Usage

The driver manager is different from the individual, driver-specific packages such as adbc_driver_postgresql.

With the driver-specific packages, you connect to the target database with the connect method provided by the package you’re using. For example, adbc_driver_postgresql.connect() or adbc_driver_sqlite.connect(). The driver shared library is bundled with the respective package and loaded invisibly for the user.

With the driver manager package, you use a single package and API regardless of the database you’re connecting to. However, the user must install the driver for their database as a separate step. Driver manifests are a first step in making this experience better for users but more work is planned to make this as straightforward as using driver-specific packages.

Low-Level API

First, create an AdbcDatabase, passing driver and (optionally) entrypoint. Then, create an AdbcConnection.

Note

See ADBC Driver Manager and Manifests for more information on what to pass as the driver argument and how the driver manager finds and loads drivers.

import adbc_driver_manager

# Note: You must install the driver shared library (.so, .dylib, .dll)
# separately
with adbc_driver_manager.AdbcDatabase(driver="PATH/TO/libadbc_driver_sqlite.so") as db:
    with adbc_driver_manager.AdbcConnection(db) as conn:
        pass

Connecting to a second database could be done in the same session using the same code just with a different driver argument.

DBAPI API

Use the DBAPI API by calling the dbapi.connect method, passing driver and (optionally) entrypoint. These arguments work the same as with the low-level API.

from adbc_driver_manager import dbapi

# Note: You must install the driver shared library (.so, .dylib, .dll)
# separately
with dbapi.connect(driver="PATH/TO/libadbc_driver_sqlite.so") as conn:
   pass

API Reference

See the API reference: adbc_driver_manager.