Add your description here
Project description
good-clickhouse
A Clickhouse client with fast_depends based dependency injection.
Sync:
from fast_depends import inject
from good_clickhouse import Clickhouse, ClickhouseProvider
@inject
def some_task(
clickhouse: Clickhouse = ClickhouseProvider(),
):
with clickhouse.cursor() as cursor:
cursor.execute('SELECT 1')
return cursor.fetchall()
Async:
from fast_depends import inject
from good_clickhouse import ClickhouseAsync, ClickhouseAsyncProvider
@inject
async def some_task(
clickhouse: ClickhouseAsync = ClickhouseAsyncProvider(),
):
async with clickhouse as client:
results = await client.execute('SELECT 1')
return results
@query decorator utility for composing queries.
from good_clickhouse import query
@query
def complex_query(table_name: str, columns: list[str], filters: dict[str, str]):
"""
select {{ columns | join(', ') }}
from {{ table_name }}
where {% for key, value in filters.items() -%}
{{ key }} {{ value }}{% if not loop.last %} and {% endif %}
{%- endfor %};
"""
columns = ["id", "name", "age"]
filters = {"age": "> 20", "name": "like 'John%'"}
rendered_query = complex_query("users", columns, filters)
print(rendered_query)
"""
> select id, name, age
> from users
> where age > 20 and name like 'John%'
"""
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
good_clickhouse-0.1.3.tar.gz
(4.8 kB
view details)
Built Distribution
File details
Details for the file good_clickhouse-0.1.3.tar.gz
.
File metadata
- Download URL: good_clickhouse-0.1.3.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e764a682e0012a11427acd534067de161fa1ce2ff27587a631c2b79ae496467c |
|
MD5 | 4f6c52bc9f69c6c0878e7e56c56cc534 |
|
BLAKE2b-256 | 8d4c3d66ab66922eea9a85cbd0b410ad832e415cddc2367d608ab64b1ab13083 |
File details
Details for the file good_clickhouse-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: good_clickhouse-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42c2799505eea11ae62b43b9711aec152629db0354ca89b6601fe58c5e08d7e6 |
|
MD5 | ea2330a49585dea469aa717088eee33e |
|
BLAKE2b-256 | be6e68431f2aaf5f5b048d111df37ab1419da2b72ae7a17846c11b8cc732b409 |