ADBC SQLite Driver

raw JSON →
1.11.0 verified Thu May 14 auth: no python

adbc-driver-sqlite provides Python bindings for the Arrow Database Connectivity (ADBC) SQLite driver, offering a DBAPI 2.0 / PEP 249-compatible interface. It allows for Arrow-native access to SQLite databases. The current version is 1.11.0, and the project generally follows a bimonthly release cadence for minor versions.

pip install adbc-driver-sqlite
error ModuleNotFoundError: No module named 'adbc_driver_sqlite'
cause The 'adbc_driver_sqlite' module is not installed in the Python environment.
fix
Install the module using pip: 'pip install adbc-driver-sqlite'.
error ImportError: cannot import name 'connect' from 'adbc_driver_sqlite'
cause The 'connect' function is located in the 'adbc_driver_sqlite.dbapi' submodule, not directly in 'adbc_driver_sqlite'.
fix
Import the function correctly: 'from adbc_driver_sqlite.dbapi import connect'.
error AttributeError: module 'adbc_driver_sqlite.dbapi' has no attribute 'fetch_arrow_table'
cause The 'fetch_arrow_table' method is available on the cursor object, not directly in the 'adbc_driver_sqlite.dbapi' module.
fix
Use the method on a cursor object: 'cursor.fetch_arrow_table()'.
error TypeError: connect() got an unexpected keyword argument 'database'
cause The 'connect' function in 'adbc_driver_sqlite.dbapi' uses 'uri' as the parameter name, not 'database'.
fix
Use the correct parameter name: 'connect(uri="your_database_uri")'.
error ValueError: invalid URI: 'your_database_uri'
cause The provided URI is not valid or the database file does not exist.
fix
Ensure the URI is correct and the database file exists at the specified location.
gotcha When connecting to an in-memory SQLite database by omitting the 'uri' parameter or using ':memory:', all connections will share the same database. To create distinct in-memory databases, use a URI like 'file::memory:?cache=shared' with a unique identifier or explicitly close connections.
fix Use unique URI filenames (e.g., 'file:mydatabase?mode=memory&cache=shared') or manage connection lifecycles carefully for in-memory databases.
gotcha SQLite's dynamic typing can lead to 'Type Promotion' and potential errors during ADBC's Arrow type inference. The driver infers types from the first batch of rows; subsequent batches attempting to convert to incompatible types will raise an error.
fix Ensure consistent data types within columns, especially when ingesting or querying large datasets with varying data. The `adbc.sqlite.query.batch_rows` option can influence how many rows are used for initial type inference.
gotcha Modifying SQLite PRAGMA settings that affect transaction state (e.g., `PRAGMA journal_mode`) may fail if executed within an implicit transaction. The ADBC Python API implicitly wraps statements in transactions.
fix Execute an explicit `COMMIT;` (or `ROLLBACK;`) before attempting to change such PRAGMA settings. Alternatively, ensure `autocommit=True` is set during connection for specific scenarios.
gotcha SQLite user-defined functions (UDFs) registered with the underlying `sqlite3` module are not directly accessible through `adbc-driver-sqlite` connections, even if they share the same in-memory database. This is due to how ADBC manages its connection to the SQLite C driver.
fix If UDFs are critical, consider using the native `sqlite3` module directly or explore if ADBC's C++ driver offers mechanisms for UDF registration that can be exposed via Python bindings in future versions.
gotcha Loading SQLite extensions requires specific connection options (`adbc.sqlite.load_extension.enabled`, `adbc.sqlite.load_extension.path`, `adbc.sqlite.load_extension.entrypoint`) to be set on the connection *after* the connection is initialized, or by using specific methods on `AdbcSqliteConnection`.
fix Consult the ADBC SQLite driver documentation for the correct sequence of setting options or calling `enable_load_extension` and `load_extension` methods to properly load SQLite extensions.
gotcha The underlying C++ SQLite driver library (`libadbc_driver_sqlite.so` on Linux, `.dylib` on macOS, `.dll` on Windows) must be discoverable by the Python package at runtime. If not installed via system package managers or not in a standard search path, this can cause import or connection errors.
fix Ensure the library is in a system-wide search path (e.g., `/usr/local/lib`) or add its directory to `LD_LIBRARY_PATH` (Linux/macOS) or `PATH` (Windows) environment variables before running Python.
pip install adbc-driver-sqlite adbc-driver-manager pyarrow
python os / libc status wheel install import disk mem side effects
3.10 alpine (musl) build_error - - - - - -
3.10 alpine (musl) - - - - - -
3.10 alpine (musl) build_error - - - - - -
3.10 alpine (musl) - - - - - -
3.10 slim (glibc) wheel 2.0s 0.02s 40M 2.0M clean
3.10 slim (glibc) - - 0.03s 40M 2.0M -
3.10 slim (glibc) wheel 3.8s 0.21s 191M 13.5M clean
3.10 slim (glibc) - - 0.26s 191M 13.5M -
3.11 alpine (musl) build_error - - - - - -
3.11 alpine (musl) - - - - - -
3.11 alpine (musl) build_error - - - - - -
3.11 alpine (musl) - - - - - -
3.11 slim (glibc) wheel 2.0s 0.05s 42M 2.2M clean
3.11 slim (glibc) - - 0.06s 42M 2.2M -
3.11 slim (glibc) wheel 3.6s 0.38s 195M 14.2M clean
3.11 slim (glibc) - - 0.36s 195M 14.2M -
3.12 alpine (musl) build_error - - - - - -
3.12 alpine (musl) - - - - - -
3.12 alpine (musl) build_error - - - - - -
3.12 alpine (musl) - - - - - -
3.12 slim (glibc) wheel 1.8s 0.04s 34M 1.8M clean
3.12 slim (glibc) - - 0.05s 34M 1.8M -
3.12 slim (glibc) wheel 3.5s 0.36s 187M 14.4M clean
3.12 slim (glibc) - - 0.44s 187M 14.4M -
3.13 alpine (musl) build_error - - - - - -
3.13 alpine (musl) - - - - - -
3.13 alpine (musl) build_error - - - - - -
3.13 alpine (musl) - - - - - -
3.13 slim (glibc) wheel 1.8s 0.04s 34M 1.6M clean
3.13 slim (glibc) - - 0.04s 34M 1.6M -
3.13 slim (glibc) wheel 3.5s 0.38s 186M 14.1M clean
3.13 slim (glibc) - - 0.54s 186M 14.1M -
3.9 alpine (musl) build_error - - - - - -
3.9 alpine (musl) - - - - - -
3.9 alpine (musl) build_error - - - - - -
3.9 alpine (musl) - - - - - -
3.9 slim (glibc) wheel 2.2s 0.03s 32M 1.9M clean
3.9 slim (glibc) - - 0.03s 32M 1.9M -
3.9 slim (glibc) wheel 4.2s 0.25s 170M 12.9M clean
3.9 slim (glibc) - - 0.30s 170M 12.9M -

Connects to an in-memory SQLite database (or a specified URI), creates a table, inserts data, and fetches results as an Arrow Table using the DBAPI 2.0 interface.

import adbc_driver_sqlite.dbapi
import os

db_uri = os.environ.get('ADBC_SQLITE_URI', 'file::memory:?cache=shared')

with adbc_driver_sqlite.dbapi.connect(uri=db_uri) as conn:
    with conn.cursor() as cur:
        cur.execute("CREATE TABLE IF NOT EXISTS users (id INTEGER, name TEXT)")
        cur.execute("INSERT INTO users (id, name) VALUES (?, ?)", (1, 'Alice'))
        cur.execute("INSERT INTO users (id, name) VALUES (?, ?)", (2, 'Bob'))
        cur.execute("SELECT * FROM users")
        result = cur.fetch_arrow_table()
        print(result)