Driver Manager

The driver manager is a library that implements the ADBC API by delegating to dynamically-loaded drivers. This allows applications to use multiple drivers simultaneously, and decouple themselves from the specific driver.

Installation

Install the appropriate driver package. You can use conda-forge, apt or dnf.

conda-forge:

  • mamba install adbc-driver-manager

You can use apt on the following platforms:

  • Debian GNU/Linux bookworm

  • Ubuntu 22.04

Prepare the Apache Arrow APT repository:

sudo apt update
sudo apt install -y -V ca-certificates lsb-release wget
sudo wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
sudo apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
rm ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
sudo apt update

Install:

  • sudo apt install libadbc-driver-manager-dev

You can use dnf on the following platforms:

  • AlmaLinux 8

  • Oracle Linux 8

  • Red Hat Enterprise Linux 8

  • AlmaLinux 9

  • Oracle Linux 9

  • Red Hat Enterprise Linux 9

Prepare the Apache Arrow Yum repository:

sudo dnf install -y epel-release || sudo dnf install -y oracle-epel-release-el$(cut -d: -f5 /etc/system-release-cpe | cut -d. -f1) || sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(cut -d: -f5 /etc/system-release-cpe | cut -d. -f1).noarch.rpm
sudo dnf install -y https://apache.jfrog.io/artifactory/arrow/almalinux/$(cut -d: -f5 /etc/system-release-cpe | cut -d. -f1)/apache-arrow-release-latest.rpm
sudo dnf config-manager --set-enabled epel || :
sudo dnf config-manager --set-enabled powertools || :
sudo dnf config-manager --set-enabled crb || :
sudo dnf config-manager --set-enabled ol$(cut -d: -f5 /etc/system-release-cpe | cut -d. -f1)_codeready_builder || :
sudo dnf config-manager --set-enabled codeready-builder-for-rhel-$(cut -d: -f5 /etc/system-release-cpe | cut -d. -f1)-rhui-rpms || :
sudo subscription-manager repos --enable codeready-builder-for-rhel-$(cut -d: -f5 /etc/system-release-cpe | cut -d. -f1)-$(arch)-rpms || :

Install:

  • sudo dnf install adbc-driver-manager-devel

Then they can be used via CMake, e.g.:

find_package(AdbcDriverPostgreSQL)

# ...

target_link_libraries(myapp PRIVATE AdbcDriverPostgreSQL::adbc_driver_postgresql_shared)

Usage

To create a database, use the AdbcDatabase API as usual, but during initialization, provide two additional parameters in addition to the driver-specific connection parameters: driver and (optionally) entrypoint. driver must be the name of a library to load, or the path to a library to load. entrypoint, if provided, should be the name of the symbol that serves as the ADBC entrypoint (see AdbcDriverInitFunc).

/* Ignoring error handling */
struct AdbcDatabase database;
memset(&database, 0, sizeof(database));
AdbcDatabaseNew(&database, NULL);
/* On Linux: loads libadbc_driver_sqlite.so
 * On MacOS: loads libadbc_driver_sqlite.dylib
 * On Windows: loads adbc_driver_sqlite.dll */
AdbcDatabaseSetOption(&database, "driver", "adbc_driver_sqlite", NULL);
/* Set additional options for the specific driver, if needed */
/* Initialize the database */
AdbcDatabaseInit(&database, NULL);
/* Create connections as usual */

API Reference

The driver manager includes a few additional functions beyond the ADBC API. See the API reference: adbc_driver_manager.h.