wclickhouse
A high-performance ClickHouse ORM for Python using Pydantic v2 and clickhouse-connect.
Features
- Pydantic v2 Integration: Define your ClickHouse tables as Pydantic models.
- Auto-Sync: Automatically creates tables and syncs schema (adds missing columns).
- Dual API: Full support for both Synchronous and Asynchronous operations.
- Bulk Insert Optimized: Built-in support for efficient bulk insertions, essential for ClickHouse performance.
- Type Safety: Automatic mapping between Python/Pydantic types and ClickHouse analytical types (Arrays, DateTime64, etc.).
- DataFrames: Native support for inserting Pandas DataFrames.
Installation
pip install wclickhouse
Quick Start
from pydantic import BaseModel
from wclickhouse import WClickHouse
from datetime import datetime
from typing import List
# 1. Define your model
class AnalyticsEvent(BaseModel):
event_id: int
event_name: str
properties: List[str]
created_at: datetime = datetime.now()
# 2. Configure connection
db_config = {
"host": "localhost",
"port": 8124,
"username": "default",
"password": "",
"database": "default"
}
# 3. Initialize (Auto-creates table)
db = WClickHouse(AnalyticsEvent, db_config)
# 4. Bulk Insert (Best for ClickHouse)
events = [
AnalyticsEvent(event_id=1, event_name="login", properties=["web", "chrome"]),
AnalyticsEvent(event_id=2, event_name="purchase", properties=["mobile", "ios"])
]
db.insert_many(events)
# 5. Query
results = db.get_all()
print(f"Total events: {len(results)}")
Performance Note
ClickHouse is an OLAP database. For best performance:
- Prefer
insert_many()over multipleinsert()calls. - Large batches (1,000 to 100,000 rows) are recommended.
- Use the
MergeTreeengine (default) for production workloads.
License
MIT
Metadata
Release files for wclickhouse 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| wclickhouse-1.0.0.tar.gz | 19.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wclickhouse-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.1 kB
Release files / wclickhouse-1.0.0.tar.gz
| Download URL | wclickhouse-1.0.0.tar.gz |
|---|---|
| Size | 19.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11d7f7842e336d359ac926f4549833151732ae4c329cdbdf3698abce7d111839
|
|
BLAKE2b-256 checksum How to use checksums |
f2c8168eeb67dd61b17247641426bc2996cf2d2a87b40bb03197363b792125bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / wclickhouse-1.0.0-py3-none-any.whl
| Download URL | wclickhouse-1.0.0-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66e858b142f5a13b084c7582a4ea79674f05f34ac72188a699a63c1d209b4d8d
|
|
BLAKE2b-256 checksum How to use checksums |
92a0ab3c6621b4bfabd207bd2ae80355e6c6db922e648d759ca009e6d635e3ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for wclickhouse 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.