mirror of
https://github.com/hanzo-ds/pool.git
synced 2026-10-30 20:37:50 +00:00
The wire protocol was the last holdout and it was not cosmetic: the Hanzo Datastore server reads X-Datastore-User, and answers a request bearing X-ClickHouse-User with 401. Verified against the live server, both directions. So a client still sending the old headers is not merely off-brand, it cannot authenticate over HTTP. Everything else follows: types, dialects, error modules, docstrings and doc links now name Datastore, and doc URLs point at docs.hanzo.ai/datastore rather than the upstream vendor's site. Zero occurrences of the old name remain. Still cut from the pinned upstream version, so behaviour is unchanged.
1.7 KiB
1.7 KiB
Datastore Pool for Python
A thread-safe connection pool for Datastore. Inspired by psycopg2 and using
datastore-driver for
connections.
Installation
pip install datastore-pool
Quick Start
from datastore_pool import ChPool
# find available settings at https://datastore-driver.readthedocs.io/en/latest/api.html#datastore_driver.Client
pool = ChPool(host="localhost")
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 datastore-server running on localhost. The easiest way is to use docker:
docker run -d -p 9000:9000 yandex/datastore-server
poetry run pytest
Building Docs
poetry run sphinx-build -M html docs/source docs/_build