clickhouse-sqlalchemy
Simple ClickHouse SQLAlchemy Dialect
What it is and what it does
ClickHouse SQLAlchemy is a SQLAlchemy dialect that bridges Python's SQLAlchemy ORM to ClickHouse, an open-source columnar database. It lets you define tables, insert data, and query ClickHouse using familiar SQLAlchemy patterns—Column definitions, declarative base classes, and session queries—rather than raw SQL or ClickHouse-specific clients. The dialect supports three transport mechanisms: native TCP (recommended), async TCP via asynch, and HTTP via requests, giving you flexibility in how your application connects to ClickHouse.
The package is in Beta status and has been actively maintained, with recent commits and a modest but stable user base. It supports Python 3.7 through 3.12 and declares no runtime dependencies, though you must separately install whichever transport library your application needs. This design keeps the package lightweight but places the burden of dependency management on you.
Use it for:
- Build a Python web application that stores analytics events in ClickHouse using SQLAlchemy ORM patterns instead of raw SQL.
- Query ClickHouse tables from a data science notebook using declarative table definitions and session queries.
- Integrate ClickHouse as a backend for a Python application that already uses SQLAlchemy for other databases.
- Set up async queries to ClickHouse in a high-concurrency service using the asynch transport.
- Migrate from another SQLAlchemy-supported database to ClickHouse with minimal ORM code changes.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
SQLAlchemy dialect for ClickHouse that enables ORM-style database access via native TCP, async TCP, or HTTP interfaces.
Yes, if you are already committed to SQLAlchemy and need ClickHouse support. The dialect is actively maintained, permissively licensed, and has no dependency bloat. However, you must manually install clickhouse-driver, asynch, or requests depending on your transport choice—verify this requirement before adding it to your project.
Install
clickhouse-sqlalchemy on PyPI
pip
pip install clickhouse-sqlalchemyuv
uv add clickhouse-sqlalchemypoetry
poetry add clickhouse-sqlalchemyInstalling clickhouse-sqlalchemy
Before you install
High install friction: the package declares no runtime dependencies, but the description indicates it requires one of clickhouse-driver, asynch, or requests to function—you must install the appropriate transport layer separately.
License in practice
MIT license is permissive; you can use this package in commercial and proprietary projects with minimal restrictions, provided you include the license notice.
Quickstart
pip install clickhouse-sqlalchemy
from sqlalchemy import create_engine
from clickhouse_sqlalchemy import make_session, get_declarative_base
uri = 'clickhouse+native://localhost/default'
engine = create_engine(uri)
session = make_session(engine)
You must separately install clickhouse-driver, asynch, or requests depending on your chosen transport (native, async native, or HTTP respectively).
Verify before relying
- Whether clickhouse-driver, asynch, or requests are truly optional or whether at least one is required at runtime
- Current state of async support via asynch and whether it is production-ready
- Whether the package works with ClickHouse versions released after the latest release date
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4,>=3.7) |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | actively maintained — 793 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,082,006/month — #3,306 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: clickhouse-sqlalchemy-0.3.2.tar.gz
Keywords: ClickHouse, db, database, cloud, analytics
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
clickhouse-connectA Python database driver for ClickHouse that…
permissive · top 1,000 on PyPI
clickhouse-migrationsApplies versioned SQL migrations to ClickHouse…
permissive · top 15,000 on PyPI
django-clickhouseIntegrates Django applications with ClickHouse,…
permissive · top 15,000 on PyPI
clickhouse-driverA native TCP driver for ClickHouse that…
permissive · top 5,000 on PyPI
clickhouse-poolProvides a thread-safe connection pool for…
copyleft · top 5,000 on PyPI
sqlalchemy-cockroachdbA SQLAlchemy dialect that enables ORM and SQL…
permissive · top 5,000 on PyPI
asynchasynch is an asynchronous ClickHouse driver…
permissive · top 5,000 on PyPI
sqlalchemy-jdbcapiSQLAlchemy dialect for JDBC and ODBC database…
permissive · top 15,000 on PyPI
sqlalchemy-solrProvides a SQLAlchemy dialect that allows you…
permissive · top 15,000 on PyPI
sqlalchemy-spannerProvides a SQLAlchemy dialect that enables…
permissive · top 5,000 on PyPI