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.10.0.tar.gz
(26.2 kB
view details)
Built Distribution
aiochsa-0.10.0-py3-none-any.whl
(19.4 kB
view details)
File details
Details for the file aiochsa-0.10.0.tar.gz
.
File metadata
- Download URL: aiochsa-0.10.0.tar.gz
- Upload date:
- Size: 26.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 674ad0bc2329f2b4e325a1960c293da5ee3340691c3c2bd4851127d353b9dbcf |
|
MD5 | 90cb19cbe59de00e12ad0507c12d39a4 |
|
BLAKE2b-256 | 9e37bd9ea9b8d006352097ffcc852294601de3afcfdde226a0c0c7689d6f548c |
Provenance
File details
Details for the file aiochsa-0.10.0-py3-none-any.whl
.
File metadata
- Download URL: aiochsa-0.10.0-py3-none-any.whl
- Upload date:
- Size: 19.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fee3b5d4f23b540a1fe361c5f03c01e795ba408cf151f4ca3a92d0161a79c44 |
|
MD5 | 5ddaebc615b87ed2c02612df89bad7b7 |
|
BLAKE2b-256 | aec55f187a0cdf5202ab777b7128044d018f5e4ec365b0f0263e61aefbfd055f |