ClickHouse Pool for Python
A thread-safe connection pool for ClickHouse. Inspired by psycopg2
and using
clickhouse-driver
for
connections.
Installation
pip install clickhouse-pool
Quick Start
from clickhouse_pool import ChPool
pool = ChPool(host="localhost")
with pool.get_client() as client:
result = client.execute("SELECT * FROM system.numbers LIMIT 5")
print(result)
pool.cleanup()
Connection Pool Size
To change the connection pool size,
pool = ChPool(connections_min=20, connections_max=40)
with pool.get_client() as client:
result = client.execute("SELECT * FROM system.numbers LIMIT 5")
print(result)
pool.cleanup()
Testing Locally
To run tests locally ensure you have an instance of clickhouse-server running on
localhost. The easiest way is to use docker:
docker run -d -p 9000:9000 yandex/clickhouse-server
poetry run pytest
Building Docs
poetry run sphinx-build -M html docs/source docs/_build