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.7.tar.gz
(4.9 kB
view details)
Built Distribution
File details
Details for the file good_clickhouse-0.1.7.tar.gz
.
File metadata
- Download URL: good_clickhouse-0.1.7.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 | 191325ca605b02b5765d98ec07354842fd0e329613deb42c84286bd49f8ca4a3 |
|
MD5 | 32f693a8a2f46c533bfe14f1b336d083 |
|
BLAKE2b-256 | b5c3104ab5394ddf1576890dac316002d29afdb46e9f48991406b088790acdd4 |
File details
Details for the file good_clickhouse-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: good_clickhouse-0.1.7-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 | 6e9b3695071175ef31ff7448bc361d4ae3d432ebc5c3c2e76bcb3e54f5296dd9 |
|
MD5 | 4d23d4b3b3972f227ddd65b52c45a920 |
|
BLAKE2b-256 | 0b8908e4b85a20636f5bba8b10fe3b49948567c1633489fa1c9c140e4cc8010e |