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.5.tar.gz
(4.9 kB
view details)
Built Distribution
File details
Details for the file good_clickhouse-0.1.5.tar.gz
.
File metadata
- Download URL: good_clickhouse-0.1.5.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 | c6d40b67997aca7d888609f3aa3232597e26232c81c58473a29279ca2f6ec26c |
|
MD5 | ee9ee3ba1eef5a1dc3896f7bcd17052b |
|
BLAKE2b-256 | b7c76e7b76e58262335a8af92b12e5e0ed8a50603777117f3c18a69633c55608 |
File details
Details for the file good_clickhouse-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: good_clickhouse-0.1.5-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 | da1db6ece45f1b3bb7d6d85a2f698ff6e636e5adef9c077ee7b08a1a6c79bf1a |
|
MD5 | 9d83c31e89fbda985a21a3cd70b7f3dc |
|
BLAKE2b-256 | 26876134f65af2e483f8ba932d9b90706f4dea41bcb9892f6e359c2d5e8ce2bc |