Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Library for accessing a ClickHouse database over native interface from the asyncio

Project description

# aioch
**aioch** is a library for accessing a ClickHouse database over native interface from the asyncio.
It wraps features of [clickhouse-driver]( for asynchronous usage.

[![Coverage Status](](
[![Build Status](](

## Installation

The package can be installed using `pip`:

pip install aioch

To install from source:

git clone
cd aioch
python install

## Usage
from datetime import datetime

import asyncio
from aioch import Client

async def exec_progress():
client = Client('localhost')

progress = await client.execute_with_progress('LONG AND COMPLICATED QUERY')
timeout = 20
started_at =

async for num_rows, total_rows in progress:
done = num_rows / total_rows if total_rows else total_rows
now =
# Cancel query if it takes more than 20 seconds to process 50% of rows.
if (now - started_at).total_seconds() > timeout and done < 0.5:
await client.cancel()
rv = await progress.get_result()

async def exec_no_progress():
client = Client('localhost')
rv = await client.execute('LONG AND COMPLICATED QUERY')

loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait([exec_progress(), exec_no_progress()]))

For more information see **clickhouse-driver** usage examples.

## Parameters

* `executor` - instance of custom Executor, if not supplied default executor will be used
* `loop` - asyncio compatible event loop

Other parameters are passing to wrapped clickhouse-driver's Client.

## License

aioch is distributed under the [MIT license](

Release history Release notifications

Download files

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

Files for aioch, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size aioch-0.0.1.tar.gz (4.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page