Skip to main content

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.4.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

good_clickhouse-0.1.4-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file good_clickhouse-0.1.4.tar.gz.

File metadata

  • Download URL: good_clickhouse-0.1.4.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

Hashes for good_clickhouse-0.1.4.tar.gz
Algorithm Hash digest
SHA256 a3214cd316ec6e2b71b0e20ff6ce3be73e342d0ce2375e8185dce19fbaee1f84
MD5 c69e432211c52b44901199214ae2ed76
BLAKE2b-256 273c9ff4a9960ec9069d69ba5f34a266ad1da71629c26de90ad2e792ebe43e41

See more details on using hashes here.

File details

Details for the file good_clickhouse-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for good_clickhouse-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 24223825e191975c15e59eb2ded49234aad2d8570eeb0fbf324352daf99442c4
MD5 3f35c97b8f652fda7e5259ab324d1a37
BLAKE2b-256 e39036d1b68af846f392c99939e7f9d6ebacfb5596ab3997aaba97f3720476ea

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page