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.6.tar.gz
(4.9 kB
view details)
Built Distribution
File details
Details for the file good_clickhouse-0.1.6.tar.gz
.
File metadata
- Download URL: good_clickhouse-0.1.6.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c47af7f1cf97e0de1523e6529b1d5851c3f19df3db60ebec5b1effdb481c6d96 |
|
MD5 | 7b97e6c0c6c9166cdc906a9752996632 |
|
BLAKE2b-256 | 1cec48296c7e937278ef6cb57cd7c758dc7c3f15d5f4171f0b19dcb4125d2a6d |
File details
Details for the file good_clickhouse-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: good_clickhouse-0.1.6-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.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | efb1c283168536095379cc4d358c667f5aeae7d10da06b419b0ff5268531bb84 |
|
MD5 | 1f75e2c366cc63585a8802293d2f57e3 |
|
BLAKE2b-256 | 7ed6c73e8aec3c49db148da649637e719d70e1b156ef37859216c0254d4a69ad |