Clickhouse Python/asyncio library for use with SQLAlchemy core
Project description
Clickhouse Python/asyncio library for use with SQLAlchemy core
Example
import aiochsa
import sqlalchemy as sa
table = sa.Table(
'test', sa.MetaData(),
sa.Column('id', sa.Integer),
sa.Column('name', sa.String),
)
async with aiochsa.connect('clickhouse://127.0.0.1:8123') as conn:
await conn.execute(
table.insert(),
[
{'id': 1, 'name': 'Alice'},
{'id': 2, 'name': 'Bob'},
],
)
rows = await conn.fetch(
table.select()
)
To add FINAL modifier use with_hint(table, 'FINAL') (see SQLAlchemy docs for details).
Configure logging to show SQL:
logging.getLogger('aiochsa.client.SQL').setLevel(logging.DEBUG)
Custom type converters
Here is an example of installing converter for ClickHouse’s DateTime type that requires and returns timezone-aware Python’s datetime object and stores it as UTC:
from datetime import datetime
import aiochsa
from aiochsa.types import DateTimeUTCType, TypeRegistry
types = TypeRegistry()
types.register(DateTimeUTCType, ['DateTime'], datetime)
conn = aiochsa.connect(dsn, types=types)
Change log
See CHANGELOG.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiochsa-0.9.2.tar.gz
(24.8 kB
view details)
File details
Details for the file aiochsa-0.9.2.tar.gz
.
File metadata
- Download URL: aiochsa-0.9.2.tar.gz
- Upload date:
- Size: 24.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/42.0.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4fd56654fcf8848547975b3e1c6a51588fef98bc1af56d5c98b26f8a660b887 |
|
MD5 | 6466bf33ba50cfbb0200aa2e83c8976e |
|
BLAKE2b-256 | b94a5c5ef4c045421784beb40287227e209fade7ac3efb5108d457cce6333c52 |