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.

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-0.10.1.tar.gz (27.3 kB view details)

Uploaded Source

Built Distribution

aiochsa-0.10.1-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aiochsa-0.10.1.tar.gz
  • Upload date:
  • Size: 27.3 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.48.0 CPython/3.8.3

File hashes

Hashes for aiochsa-0.10.1.tar.gz
Algorithm Hash digest
SHA256 83b369aa80db722e46aaa2831ba9dcac2a202ee38651207d3d78a1eb334c455d
MD5 d33a4535ccc5703e02fd00b92d6ded2c
BLAKE2b-256 c4eae85591f459209c0ebffe3786a08dadb2d85152031fc5f2aec462d6d5ba92

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiochsa-0.10.1-py3-none-any.whl
  • Upload date:
  • Size: 20.3 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.48.0 CPython/3.8.3

File hashes

Hashes for aiochsa-0.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 036a56d7ee2e6a99be92d304a2903d31a11b6a667fd350f8931b24ade76712d5
MD5 ee0ceb5c92e8577b9ef5eec306538dbc
BLAKE2b-256 c600ac0fdbc4d130f13f9e0cb825b3628e5717aff2ea9190e712fd1d355d05ae

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