Skip to main content

Generic SQLAlchemy dialect for any ADBC driver (Flight SQL, PostgreSQL, SQLite, Snowflake, BigQuery).

Project description

sqlalchemy-adbc

PyPI License: Apache 2.0

Generic SQLAlchemy dialect for any Apache Arrow ADBC driver — so any tool that speaks SQLAlchemy (pandas, marimo, Superset, dbt, Polars) can read and write against Flight SQL, PostgreSQL, SQLite, Snowflake, and BigQuery through the Arrow-native wire path.

Why this exists

ADBC drivers speak Python DBAPI and return results as Arrow record batches — zero per-row materialization, no driver-specific JDBC/ODBC install. But most of the Python ecosystem wires into databases through SQLAlchemy, and ADBC doesn't ship a dialect. This package is a thin translation layer: SQLAlchemy URL → ADBC db_kwargs → DBAPI connection.

Install

pip install sqlalchemy-adbc

# With a driver extra:
pip install "sqlalchemy-adbc[flightsql]"
pip install "sqlalchemy-adbc[postgresql]"
pip install "sqlalchemy-adbc[sqlite]"
pip install "sqlalchemy-adbc[snowflake]"
pip install "sqlalchemy-adbc[bigquery]"

Quickstart

import sqlalchemy

# Flight SQL
engine = sqlalchemy.create_engine(
    "adbc+flightsql://flight-sql.example.com:443?tls=true",
    connect_args={"db_kwargs": {
        "adbc.flight.sql.authorization_header": f"Bearer {token}",
    }},
)

# SQLite
engine = sqlalchemy.create_engine("adbc+sqlite:///path/to/db.sqlite")

# PostgreSQL
engine = sqlalchemy.create_engine(
    "adbc+postgresql://user:pass@host:5432/mydb"
)

# Works with pandas, Polars, marimo SQL cells, etc.
import pandas as pd
df = pd.read_sql("SELECT 1 AS n", engine)

URL forms

Driver URL
Flight SQL adbc+flightsql://host:port?tls=true&authorization=...
Flight SQL adbc+flightsql://user:TOKEN@host:port?tls=true (bearer)
PostgreSQL adbc+postgresql://user:pass@host:port/database
SQLite adbc+sqlite:///path/to/db or adbc+sqlite:///:memory:
Snowflake adbc+snowflake://user:pass@account/db/schema?warehouse=W
BigQuery adbc+bigquery:///my-project?dataset=my_dataset

Flight SQL query-string options

Key Meaning
tls=true Use grpc+tls:// instead of grpc://
authorization=... Sets the ADBC AUTHORIZATION_HEADER db_kwarg
header.<name>=<v> Forwarded via ADBC's RPC_CALL_HEADER_PREFIX
(any other key) Passed through as a db_kwarg verbatim

Status

Alpha — the core dialect machinery works for simple SELECT / INSERT / CREATE TABLE use. More advanced SQLAlchemy features are still to come; the known gaps are called out below so you don't waste time debugging a missing feature:

  • Table reflection (MetaData.reflect()): not implemented. The ADBC driver exposes table/column metadata via the Arrow-based GetObjects call, but this library doesn't yet wire that into SQLAlchemy's Inspector contract. PRs welcome.
  • Alembic autogenerate: follows from reflection — won't work until reflection lands. alembic upgrade against already-written migrations is fine (it's pure SQL).
  • PostgreSQL-specific types (JSONB, ARRAY, UUID, TSTZMULTIRANGE, …): ADBC's Arrow-over-the-wire codec returns these as strings / lists of primitives, not as SQLAlchemy's typed objects. If you need ORM-level round-tripping of PG-specific types, use psycopg2 until we add a type compiler.
  • Query parameterization: uses ADBC's native $1-style placeholders for PostgreSQL and ? for SQLite. Flight SQL and Snowflake delegate to the driver's default.

PRs welcome.

Tests: 52+ passing against ADBC SQLite + URL/DSN translators on Python 3.9–3.13.

Development

git clone https://github.com/drls-io/sqlalchemy-adbc
cd sqlalchemy-adbc
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest
ruff check src/ tests/

Releasing

Publishing is automated via PyPI trusted publishing (OIDC, no API tokens). One-time setup on pypi.org: add a pending publisher for project sqlalchemy-adbc, owner drls-io, repository sqlalchemy-adbc, workflow publish.yml, environment pypi. Same for TestPyPI if you want dry-runs.

Cutting a release:

# 1. Bump version in pyproject.toml
# 2. Commit, tag, push
git commit -am "chore: release v0.1.1"
git tag v0.1.1
git push && git push --tags

The Publish to PyPI workflow fires on the tag, builds sdist+wheel, and uploads to pypi.org. For TestPyPI dry-runs use workflow_dispatch with target testpypi.

License

Apache-2.0. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlalchemy_adbc-0.2.0.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqlalchemy_adbc-0.2.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file sqlalchemy_adbc-0.2.0.tar.gz.

File metadata

  • Download URL: sqlalchemy_adbc-0.2.0.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sqlalchemy_adbc-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7f67dc0075cbc80f7bf5ed48c9bb1ce98e155393e182971b9b9cb4cf10e5da27
MD5 e9d0c45ab6c840aaefd53f92c678418c
BLAKE2b-256 ce5b64aa02bfbb3c679dd6282b4e58e4c5f45af4e336ed2164379a6f58b5a64e

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlalchemy_adbc-0.2.0.tar.gz:

Publisher: publish.yml on drls-io/sqlalchemy-adbc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sqlalchemy_adbc-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: sqlalchemy_adbc-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sqlalchemy_adbc-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 610c56b78c37398af1c45b52123365a3ba253bf491e68494da9a95fdbf0231de
MD5 77db1182e3669c40b64ae5ca753614b7
BLAKE2b-256 6e64842ff9c753c392294fc40b985901fa6123b52ed420df842c89b272d2e12d

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlalchemy_adbc-0.2.0-py3-none-any.whl:

Publisher: publish.yml on drls-io/sqlalchemy-adbc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page