A thread-safe connection pool for ClickHouse.
Project description
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()
with pool.get_client() as client:
# execute sql and print the result
result = client.execute("SELECT * FROM system.numbers LIMIT 5")
print(result)
# always close all connections in the pool once you're done with it
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)
# always close all connections in the pool once you're done with it
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
python tests.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
clickhouse-pool-0.4.2.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for clickhouse_pool-0.4.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f524ccd2c15a39fffd881270a3db902253bf2c0e8cfaceea1252bb59e867714 |
|
MD5 | 26cdeff67c40af1783a00c47668d1e2c |
|
BLAKE2b-256 | 6e7df9fd0cf04d7246fdf50f920724a0ebb66d195bd39be8719eaccadc249d49 |