Driver Manager Recipes#
Load a driver from a shared library (DuckDB)#
Recipe source: driver_manager_duckdb.py
The ADBC driver manager can load a driver from a shared library. For drivers provided by the Arrow project, you don’t need to worry about this; the Python package will take care of this for you. Other drivers may need configuration, though. We’ll use DuckDB as an example.
25import duckdb 26 27import adbc_driver_manager.dbapi
The driver manager needs the path to the shared library. It also needs the name of the entrypoint function. Both of these should be found in the driver’s documentation.
32conn = adbc_driver_manager.dbapi.connect( 33 driver=duckdb.__file__, 34 entrypoint="duckdb_adbc_init", 35)
Once we provide that, everything else about the connection is the same as usual.
40with conn.cursor() as cur: 41 cur.execute("SELECT 1") 42 assert cur.fetchone() == (1,) 43 44conn.close()