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%'
"""
Release files for good-clickhouse 0.2.24
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| good_clickhouse-0.2.24.tar.gz | 62.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| good_clickhouse-0.2.24-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 74.4 kB
Release files / good_clickhouse-0.2.24.tar.gz
| Download URL | good_clickhouse-0.2.24.tar.gz |
|---|---|
| Size | 62.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a2e0b739c4d1541da8948e92859d531ff56bf8ee95d210b08cf37b650f5f0eee
|
|
BLAKE2b-256 checksum How to use checksums |
c2153a70c3b0c24faf174118fdcbdaf3a1a00f1391d707053133535ed99c543a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Release files / good_clickhouse-0.2.24-py3-none-any.whl
| Download URL | good_clickhouse-0.2.24-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fabe88c6634b4ee2bc3a853c04b4766117b409dd38585e208ec5c0fa1a277f20
|
|
BLAKE2b-256 checksum How to use checksums |
9d8ffaca2b10cfc82ec42fb58f9bd6a478fe1f47f02acb976a27239901de95b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|