Skip to main content

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

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.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: clickhouse_pool-0.6.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.11 Linux/6.11.0-1018-azure

File hashes

Hashes for clickhouse_pool-0.6.1.tar.gz
Algorithm Hash digest
SHA256 9a888d90c8661eb0cf3c459791d800a21a226c960a6872c95561ec5fab5a2ebf
MD5 fd0b1eaecb8a626963d10433f8faa98d
BLAKE2b-256 3357de9a73299f21cfa09a086a984147f52b7ede3efcd5e07968e84c4d098a9a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: clickhouse_pool-0.6.1-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.11 Linux/6.11.0-1018-azure

File hashes

Hashes for clickhouse_pool-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bacf3fb138a45d29b4300e1646b425b4c5bd28ec953b24840ba5d64203eb6b2a
MD5 53781079b15f839f1ab6ced0ba51166b
BLAKE2b-256 c4873bfd9e3d775b7ac1e4792c3d2ffb4a17eda1665be1ff2a813a7e4b5ef56a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 files

0.6.0

2 files

0.5.3

2 files

0.5.0

2 files

0.4.3

2 files

0.4.2

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page