Skip to main content

An experimental wrapper around aiochclient to use it with SQLAlchemy

Project description

An experimental 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()
    )

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.5.tar.gz (15.1 kB view hashes)

Uploaded Source

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