Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiochsa-1.2.0.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

aiochsa-1.2.0-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file aiochsa-1.2.0.tar.gz.

File metadata

  • Download URL: aiochsa-1.2.0.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.5

File hashes

Hashes for aiochsa-1.2.0.tar.gz
Algorithm Hash digest
SHA256 5277a38c5d6a06c30f8cf919480f31d4833b6446570b507405db53d26e70f904
MD5 9049a1f8404d473ecc60e53c102fbae2
BLAKE2b-256 e856ae52688e3bdc0208df03fba11a03b2fa3fa02b3ba3c3e4dc4df647fe395d

See more details on using hashes here.

File details

Details for the file aiochsa-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: aiochsa-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.5

File hashes

Hashes for aiochsa-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2d5912ea93b5725bc9991ddb1efe3818ccfb487a559580401750f0e601a91c53
MD5 ede91c555b08437197cb6d7efb501e5e
BLAKE2b-256 f64511c9b89e2f52130f42399bb0eb415a18340c739626b131baad2fc62e8787

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page