Metadata-Version: 2.4
Name: wclickhouse
Version: 1.0.0
Summary: A light, simple, and high-performance ClickHouse ORM for Python using Pydantic v2.
Project-URL: Homepage, https://github.com/wisrovi/wclickhouse
Project-URL: Repository, https://github.com/wisrovi/wclickhouse
Project-URL: Issues, https://github.com/wisrovi/wclickhouse/issues
Author-email: William Steve Rodriguez Villamizar <wisrovi.rodriguez@gmail.com>
License: MIT License
        
        Copyright (c) 2025 William Rodriguez
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: async,clickhouse,olap,orm,performance,pydantic
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: clickhouse-connect>=0.6.0
Requires-Dist: httpx>=0.24.0
Requires-Dist: loguru>=0.7.0
Requires-Dist: pandas>=2.0.0
Requires-Dist: pydantic>=2.0.0
Provides-Extra: dev
Requires-Dist: black>=23.0.0; extra == 'dev'
Requires-Dist: mypy>=1.7.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
Requires-Dist: pytest>=7.4.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Description-Content-Type: text/markdown

# 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

```bash
pip install wclickhouse
```

## Quick Start

```python
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:
1. Prefer `insert_many()` over multiple `insert()` calls.
2. Large batches (1,000 to 100,000 rows) are recommended.
3. Use the `MergeTree` engine (default) for production workloads.

## License

MIT
