ClickHouse dialect for SQLAlchemy to ClickHouse database.
Documentation is available at https://clickhouse-sqlalchemy.readthedocs.io.
Supported interfaces:
- native [recommended] (TCP) via clickhouse-driver
- 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
And query inserted data
ClickHouse SQLAlchemy is distributed under the MIT license.