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.
Development
Prerequizites: Python (use pyenv to manage multiple versions), pip, tox, coverage, docker, docker-compose.
Running tests:
# Run whole tests matrix:
tox
# Run test with specific Python version only:
tox -e py38
# Test with specific Clickhouse version:
tox -e py38 -- --clickhouse-version=21.2.2.8
# Run specified test(s):
tox -e py38 -- tests/test_execute.py::test_aggregate_function
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
Built Distribution
File details
Details for the file aiochsa-1.0.0.tar.gz
.
File metadata
- Download URL: aiochsa-1.0.0.tar.gz
- Upload date:
- Size: 29.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aba47cf93cda060402a3c9130c6ccae2a3777771c7c89d049896b34287a0745d |
|
MD5 | 809f41aa590baaefd28d0d98add8d136 |
|
BLAKE2b-256 | f44b57adff53feb43a57360e985f85132484aaf5334f06a9ce87125a16a67ad9 |
Provenance
File details
Details for the file aiochsa-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: aiochsa-1.0.0-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f705263ddd712468ab43c31c65091a150394bc8d0a6055814b948c01b29c42b |
|
MD5 | e60a9f4d77cb28b656eda9afc2331714 |
|
BLAKE2b-256 | 44981150e3a7b1a34d9d4cad4ddf11bdb49fd7f6bac677fb35a67f78fe3d27ac |