Skip to main content

a thread-safe connection pool for ClickHouse

Project description

ClickHouse Pool for Python

PyPI PyPI - License Read the Docs

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

# find available settings at https://clickhouse-driver.readthedocs.io/en/latest/api.html#clickhouse_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 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

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

clickhouse_pool-0.6.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

clickhouse_pool-0.6.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file clickhouse_pool-0.6.0.tar.gz.

File metadata

  • Download URL: clickhouse_pool-0.6.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-1007-azure

File hashes

Hashes for clickhouse_pool-0.6.0.tar.gz
Algorithm Hash digest
SHA256 68d785ff8275fc5a47f36b014f56764fdd222716af798a8f91bee56585749a3c
MD5 fc2a4609afea8f9534fc0b04f2664396
BLAKE2b-256 97180937e96df7387e070345bfa99ec209ffa20f9d2b018715af714767c58b28

See more details on using hashes here.

File details

Details for the file clickhouse_pool-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: clickhouse_pool-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-1007-azure

File hashes

Hashes for clickhouse_pool-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e14aee4236a02789d4af752690c3f4430d1a6ae4188ae0df127de5814152ee3
MD5 e4b900b300aa6c56bd9ae8b9a26fd327
BLAKE2b-256 aa258848822ee6a55b9b3b0706113123c26064851fe4f905f70c2a8835fad245

See more details on using hashes here.

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