Skip to the content.

DuckDB SQLAlchemy dialect

This project provides a production-ready SQLAlchemy dialect for DuckDB and MotherDuck. Use SQLAlchemy Core and ORM APIs with DuckDB locally or in MotherDuck without manual driver workarounds.

What you get

Quick start

from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.orm import declarative_base, Session

Base = declarative_base()

class User(Base):
    __tablename__ = "users"
    id = Column(Integer, primary_key=True)
    name = Column(String)

engine = create_engine("duckdb:///:memory:")
Base.metadata.create_all(engine)

with Session(engine) as session:
    session.add(User(name="Ada"))
    session.commit()

Next steps