skillfed

duckdb-engine

SQLAlchemy driver for duckdb

duckdb-engine v0.17.0 2.1M downloads/30d#3,292 on PyPI495
Permissive license MIT Active released

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-engine

uv

uv add duckdb-engine

poetry

poetry add duckdb-engine

Installing 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

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9

Tags

sqlalchemy duckdb driverduckdb sql database adapterin-memory sql query engineduckdb orm integrationsqlalchemy dialect duckdbpython sql database connectorduckdb dataframe queries
sqlalchemy-dialectduckdb-integrationanalytics-sql

More Front-Ends packages