Skip to main content

ClickHouse SQLAlchemy

ClickHouse dialect for SQLAlchemy to ClickHouse database.

This is clickhouse-sqlalchemy-ng, a maintained fork of clickhouse-sqlalchemy by Konstantin Lebedev, which has had no release since 0.3.2. It keeps the clickhouse_sqlalchemy import name and the clickhouse:// URL schemes, so it is a drop-in replacement.

https://img.shields.io/pypi/v/clickhouse-sqlalchemy-ng.svg https://coveralls.io/repos/github/akurdyukov/clickhouse-sqlalchemy/badge.svg?branch=master https://img.shields.io/pypi/l/clickhouse-sqlalchemy-ng.svg https://img.shields.io/pypi/pyversions/clickhouse-sqlalchemy-ng.svg https://img.shields.io/pypi/dm/clickhouse-sqlalchemy-ng.svg https://github.com/akurdyukov/clickhouse-sqlalchemy/actions/workflows/actions.yml/badge.svg

Installation

pip install clickhouse-sqlalchemy-ng

Both packages install the same clickhouse_sqlalchemy module, so uninstall the original first: pip uninstall clickhouse-sqlalchemy.

Documentation

Documentation of the original project is available at https://clickhouse-sqlalchemy.readthedocs.io and applies to this fork; see CHANGELOG.md for what changed since 0.3.2.

Usage

Supported interfaces:

  • native [recommended] (TCP) via clickhouse-driver <https://github.com/mymarilyn/clickhouse-driver>

  • async native (TCP) via asynch <https://github.com/long2ice/asynch>

  • http via requests

Define table

from sqlalchemy import create_engine, Column, MetaData

from clickhouse_sqlalchemy import (
    Table, make_session, get_declarative_base, types, engines
)

uri = 'clickhouse+native://localhost/default'

engine = create_engine(uri)
session = make_session(engine)
metadata = MetaData(bind=engine)

Base = get_declarative_base(metadata=metadata)

class Rate(Base):
    day = Column(types.Date, primary_key=True)
    value = Column(types.Int32)

    __table_args__ = (
        engines.Memory(),
    )

Rate.__table__.create()

Insert some data

from datetime import date, timedelta

from sqlalchemy import func

today = date.today()
rates = [
    {'day': today - timedelta(i), 'value': 200 - i}
    for i in range(100)
]

And query inserted data

session.execute(Rate.__table__.insert(), rates)

session.query(func.count(Rate.day)) \
    .filter(Rate.day > today - timedelta(20)) \
    .scalar()

License

ClickHouse SQLAlchemy is distributed under the MIT license.

Metadata

Release files for clickhouse-sqlalchemy-ng 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clickhouse-sqlalchemy-ng 0.4.0
File Size Uploaded Provenance Actions
clickhouse_sqlalchemy_ng-0.4.0.tar.gz 47.2 kB With provenance Details for clickhouse_sqlalchemy_ng-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for clickhouse-sqlalchemy-ng 0.4.0
File Interpreter ABI Platform Actions
clickhouse_sqlalchemy_ng-0.4.0-py3-none-any.whl Python 3 none any Details for clickhouse_sqlalchemy_ng-0.4.0-py3-none-any.whl

Total release size: 102.8 kB

Release files / clickhouse_sqlalchemy_ng-0.4.0.tar.gz

Download URL clickhouse_sqlalchemy_ng-0.4.0.tar.gz
Size 47.2 kB
Tags Source
SHA-256 checksum
How to use checksums
564a723033607c1a3ba9fc1baf113a925c050bcc2e43e0928ae817859e6918b0
BLAKE2b-256 checksum
How to use checksums
d9b942d3cb69f2f16367963749e63578faa13abf97db5c1d3c4ddabbc758315c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Release files / clickhouse_sqlalchemy_ng-0.4.0-py3-none-any.whl

Download URL clickhouse_sqlalchemy_ng-0.4.0-py3-none-any.whl
Size 55.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85c24cabbf284779671bdc2c78b0273d413ea386938a73676022cbc30d1e1464
BLAKE2b-256 checksum
How to use checksums
4e7c50887d485a883599ff4b33d978064e62da7f56a83c25caa4cb451bef1a8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Security for clickhouse-sqlalchemy-ng 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for clickhouse_sqlalchemy_ng-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page