duckdb-engine
SQLAlchemy driver for duckdb
What it is and what it does
duckdb_engine is a SQLAlchemy dialect that bridges DuckDB and SQLAlchemy, letting you write standard SQLAlchemy code against DuckDB databases. It works by registering itself as a SQLAlchemy driver, so you can create engines with the duckdb:// URL scheme and use the full ORM and expression language as you would with any other database. The package depends on duckdb, sqlalchemy, and packaging.
The driver supports both in-memory and file-backed DuckDB instances, pandas DataFrame registration, Alembic migrations, extension preloading, and fsspec filesystem registration. It derives from the PostgreSQL dialect, which means some PostgreSQL-specific features (like SERIAL auto-increment) are not directly supported and require workarounds such as SQLAlchemy Sequence objects. The package is designed for developers who want to use DuckDB's analytical capabilities within a familiar SQLAlchemy interface.
Use it for:
- Build data analysis pipelines using SQLAlchemy ORM against DuckDB for fast in-memory or persistent queries
- Query pandas DataFrames registered with DuckDB using standard SQL through SQLAlchemy
- Prototype or migrate applications from PostgreSQL to DuckDB by swapping the connection string
- Run interactive SQL queries in Jupyter notebooks with IPython-SQL and duckdb_engine
- Manage database schema evolution with Alembic migrations on DuckDB-backed applications
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A SQLAlchemy driver that enables you to use DuckDB as a database backend, allowing standard SQLAlchemy ORM and SQL operations against DuckDB instances.
Yes. The package has low install friction, active maintenance, no known vulnerabilities, and permissive licensing. It is a solid choice if you need SQLAlchemy integration with DuckDB. Be aware of PostgreSQL-derived dialect quirks (e.g., SERIAL not supported, use Sequence instead) and test edge cases involving advanced SQL features.
Install
duckdb-engine on PyPI
pip
pip install duckdb-engineuv
uv add duckdb-enginepoetry
poetry add duckdb-engineInstalling duckdb-engine
Before you install
Low friction installation with three straightforward runtime dependencies (duckdb, packaging, sqlalchemy). The package is actively maintained with recent commits and has been stable since its early releases.
License in practice
MIT license is permissive and places no restrictions on use, modification, or distribution in proprietary or open-source contexts.
Quickstart
from sqlalchemy import Column, Integer, Sequence, String, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm.session import Session
Base = declarative_base()
class FakeModel(Base):
__tablename__ = "fake"
id = Column(Integer, Sequence("fakemodel_id_sequence"), primary_key=True)
name = Column(String)
eng = create_engine("duckdb:///:memory:")
Base.metadata.create_all(eng)
session = Session(bind=eng)
session.add(FakeModel(name="Frank"))
session.commit()
Requires Python 3.9 or later; DuckDB does not support SERIAL datatype, so auto-incrementing IDs must use SQLAlchemy Sequence objects instead.
Verify before relying
- Whether all DuckDB configuration parameters documented in DuckDB's configuration guide are fully supported through connect_args
- Current status of pandas.read_sql() chunksize compatibility (note indicates it was resolved in duckdb >=0.5.0, but confirmation needed)
- Extent of PostgreSQL feature parity and which specific SQL constructs may fail due to DuckDB's PostgreSQL parser limitations
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4,>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — duckdb, packaging, sqlalchemy |
| Maintenance | actively maintained — 503 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,106,368/month — #3,292 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: duckdb_engine-0.17.0-py3-none-any.whl
Tags
More Front-Ends packages
SQLAlchemy is a Python SQL toolkit and Object…
permissive · top 100 on PyPI
psycopg2-binarypsycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
alembicAlembic generates and manages database schema…
permissive · top 1,000 on PyPI
weaviate-clientA Python client library for connecting to and…
permissive · top 1,000 on PyPI
databricks-sql-connectorA Python client library that connects to…
permissive · top 1,000 on PyPI
psycopgPsycopg 3 is a PostgreSQL database adapter for…
copyleft · top 1,000 on PyPI
databricks-sqlalchemyProvides a SQLAlchemy 2.0 dialect that bridges…
permissive · top 1,000 on PyPI
sqlalchemy-jdbcapiSQLAlchemy dialect for JDBC and ODBC database…
permissive · top 15,000 on PyPI
sqlalchemy-hanaProvides a SQLAlchemy dialect that enables you…
permissive · top 15,000 on PyPI
duckdbDuckDB is an in-process SQL database engine…
permissive · top 1,000 on PyPI
sqlalchemy-trinoProvides a SQLAlchemy dialect for connecting to…
permissive · top 15,000 on PyPI
dbt-duckdbdbt-duckdb connects dbt (a SQL/Python…
permissive · top 5,000 on PyPI
duckdb-extension-httpfsEnables DuckDB to query data over HTTP/HTTPS by…
permissive · top 15,000 on PyPI
jupysqlAdds SQL execution to Jupyter and IPython…
permissive · top 15,000 on PyPI
duckdb-extensionsPackages DuckDB core extensions as…
permissive · top 15,000 on PyPI
singlestoredbProvides a DB-API 2.0 compatible Python…
permissive · top 15,000 on PyPI