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.11.0.tar.gz
(28.1 kB
view details)
Built Distribution
aiochsa-0.11.0-py3-none-any.whl
(20.1 kB
view details)
File details
Details for the file aiochsa-0.11.0.tar.gz
.
File metadata
- Download URL: aiochsa-0.11.0.tar.gz
- Upload date:
- Size: 28.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57423ce2d214efe3652580bc9cb32ff1e8c45917ba1e7d28662b0f3ab0fcfa99 |
|
MD5 | 867eb4f77c056ff844767a491ac6ffc2 |
|
BLAKE2b-256 | a1c43027251a0766c9899ae54818375b535dd5dd0fc632e8ead3dc32d2e12840 |
File details
Details for the file aiochsa-0.11.0-py3-none-any.whl
.
File metadata
- Download URL: aiochsa-0.11.0-py3-none-any.whl
- Upload date:
- Size: 20.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43770fee646f3e11ddaa6cb5ca850757bf7a1a56d834a577ea15a367d3a12d24 |
|
MD5 | 63b0e805a177a14df84b3b002398435a |
|
BLAKE2b-256 | fec5a40f0ad2d0384a9c8369ac09c9e855218c9fd2a28f35456448f9fb668288 |