High-performance ClickHouse client with native protocol and Arrow integration
Project description
py-clickhouse-arrow
Python bindings for clickhouse-arrow - a high-performance ClickHouse client with native protocol and Arrow integration.
Architecture
This package follows the Polars monorepo model where Python bindings (py-polars) live alongside the core Rust library (polars) in the same repository. This enables:
- Atomic changes across Rust and Python APIs in single commits
- Natural version synchronisation between packages
- Simpler CI/CD with unified build and test pipelines
The Rust crate implementing the Python bindings is called py-clickhouse-arrow to distinguish from the wrapped Rust crate clickhouse-arrow. The Python package is named clickarrow (since clickhouse-arrow is already taken on PyPI by a different HTTP-based implementation).
Installation
pip install clickarrow
Quick Start
import clickhouse_arrow
# Connect with convenience function
client = clickhouse_arrow.connect("localhost:9000")
# Query returns PyArrow RecordBatches
batches = client.query("SELECT * FROM system.numbers LIMIT 10")
for batch in batches:
print(batch.to_pandas())
# Insert PyArrow data
import pyarrow as pa
batch = pa.RecordBatch.from_pydict({
"id": pa.array([1, 2, 3], type=pa.uint64()),
"name": pa.array(["a", "b", "c"]),
})
client.execute("CREATE TABLE test (id UInt64, name String) ENGINE = Memory")
client.insert("INSERT INTO test", batch)
Builder Pattern
For more control over connection settings:
client = (
clickhouse_arrow.ClientBuilder()
.endpoint("localhost:9000")
.username("default")
.password("")
.database("my_db")
.compression("lz4") # or "zstd" or "none"
.tls(True)
.build()
)
Features
- Native Protocol: Direct TCP connection to ClickHouse (not HTTP)
- Zero-Copy Arrow: Data transfer via PyArrow with no serialisation overhead
- Compression: LZ4 (default) and ZSTD support
- TLS: Secure connections with certificate verification
Development
Development uses uv for Python environment management and maturin for building the Rust extension.
Setup
cd py-clickhouse-arrow
# Create virtual environment and install dev dependencies
uv sync --group dev
# Build the extension in development mode
uv run maturin develop
# Run tests
uv run pytest
Building Wheels
# Build release wheel
uv run maturin build --release
# Build with specific Python version
uv run maturin build --release -i python3.11
Code Quality
# Format and lint Python code
uv run ruff format .
uv run ruff check .
# Rust formatting and linting (from workspace root)
cargo fmt -p py-clickhouse-arrow
cargo clippy -p py-clickhouse-arrow
API Reference
Exceptions
All exceptions inherit from ClickHouseError:
ConnectionError- Network, timeout, connection issuesQueryError- Protocol, parsing, type errorsSerializationError- Data serialisation failuresServerError- ClickHouse server exceptionsConfigurationError- Client configuration issues
Client Methods
query(sql)→List[pyarrow.RecordBatch]insert(sql, batch)→Noneexecute(sql)→Nonehealth_check(ping=False)→Noneshutdown()→None
License
Apache-2.0
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clickarrow-0.1.0.tar.gz.
File metadata
- Download URL: clickarrow-0.1.0.tar.gz
- Upload date:
- Size: 456.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a50df94428df4f4836dc3659331567bf8427ccb5c3727b3657b280ef2d69838
|
|
| MD5 |
fe3493fb555dae787796d35599d42d97
|
|
| BLAKE2b-256 |
b8847f47b5a71965561640a1906fd9baef7872a5e4a76e1abeb64f2e88703e38
|
File details
Details for the file clickarrow-0.1.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: clickarrow-0.1.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 4.6 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3579c302af3b78ed88b42e5bbdd0b20d66c16dc17f12f7b7fc5f3bc1bcb6565d
|
|
| MD5 |
887c97c6b91426926f6e61ca57abdbbb
|
|
| BLAKE2b-256 |
008440cf1bbad76b0143d3dc6485a925c70381d11feca59676fbe28f14f01fa7
|
File details
Details for the file clickarrow-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: clickarrow-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 5.6 MB
- Tags: CPython 3.9+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9637d8c91442dcb23b8d46a3d3d63d5ff1fb421bedbabcedc990e9151d4f9912
|
|
| MD5 |
21bc187dd9001fe05d123b0785b92641
|
|
| BLAKE2b-256 |
1ebb8e0648afaf1f7b72844c823db7a5966bc0ca0c4afb2e182fa3e6028f1997
|
File details
Details for the file clickarrow-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: clickarrow-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.6 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba79c1379d1d9ed89b7e09eba6e264d5116f41ea88ed93d0e79ba66bf4670540
|
|
| MD5 |
30b1d079a1a876b9414d034fccd06943
|
|
| BLAKE2b-256 |
cd992ca89ba7036b4fd54dcc34b5c832669c1d71bdf0ab31b2f8ed7b8ee18175
|
File details
Details for the file clickarrow-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: clickarrow-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.0 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33f3e9cadbd83d35760a1b0b4497e36b5e7ab0ce1c9027a5a4dcf25927aef69f
|
|
| MD5 |
594d84e840c24e1503f49bf97aa100c3
|
|
| BLAKE2b-256 |
6f56b8d3647a3cc1cf32f5c2dd93241a2caada63056cd82835bcec31c5128914
|
File details
Details for the file clickarrow-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: clickarrow-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.7 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2fe51650bc55b1ae89f464768789a9cbac668a69be32fdc762333d47d913904
|
|
| MD5 |
15642e86ba00fe9f66d7943be8205b62
|
|
| BLAKE2b-256 |
2253d0dab60f3a403941e5f31740bf6679d31fb75e90f01b5244caedc807bb28
|
File details
Details for the file clickarrow-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: clickarrow-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 5.1 MB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48cafd76fdeb1122ef4e524c0fefcf1d222809f02366b880b83ebe3f57537839
|
|
| MD5 |
77accc221e09a40921c2ea253f1bd0b5
|
|
| BLAKE2b-256 |
ce0da8d74ff98e5d366ac1ac64c362f6f8dd46fa8d19a8268795166cc83cb83e
|