Simple ClickHouse SQLAlchemy Dialect
Project Links
Meta
Author: Konstantin Lebedev
Requires Python: >=3.7, <4
Classifiers
Development Status
- 4 - Beta
Environment
- Console
Intended Audience
- Developers
- Information Technology
License
- OSI Approved :: MIT License
Operating System
- OS Independent
Programming Language
- SQL
- Python :: 3
- Python :: 3.6
- Python :: 3.7
- Python :: 3.8
- Python :: 3.9
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
Topic
- Database
- Software Development
- Software Development :: Libraries
- Software Development :: Libraries :: Application Frameworks
- Software Development :: Libraries :: Python Modules
- Scientific/Engineering :: Information Analysis
ClickHouse SQLAlchemy
ClickHouse dialect for SQLAlchemy to ClickHouse database.
Documentation
Documentation is available at https://clickhouse-sqlalchemy.readthedocs.io.
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.
0.3.2
Jun 12, 2024
0.3.1
Mar 14, 2024
0.3.0
Nov 05, 2023
0.2.9
Feb 03, 2025
0.2.8
Jan 30, 2025
0.2.7
Oct 18, 2024
0.2.6
Mar 25, 2024
0.2.5
Oct 29, 2023
0.2.4
May 02, 2023
0.2.3
Nov 24, 2022
0.2.2
Aug 24, 2022
0.2.1
Jun 13, 2022
0.2.0
Feb 20, 2022
0.1.12
Jul 31, 2025
0.1.11
Mar 25, 2024
0.1.10
Jun 06, 2022
0.1.9
May 07, 2022
0.1.8
Feb 03, 2022
0.1.7
Nov 18, 2021
0.1.6
Mar 15, 2021
0.1.5
Dec 14, 2020
0.1.4
Apr 30, 2020
0.1.3
Apr 04, 2020
0.1.2
Nov 06, 2019
0.1.1
Oct 30, 2019
0.1.0
Oct 30, 2019
0.0.10
Feb 05, 2019
0.0.9
Jan 21, 2019
0.0.8
Nov 25, 2018
0.0.7
Jul 31, 2018
0.0.6
Jul 20, 2018
0.0.5
Nov 06, 2017
0.0.4
Oct 02, 2017
0.0.3
Jul 16, 2017
0.0.2
Jun 22, 2017
0.0.1
Mar 30, 2017
Files in release
No dependencies