Skip to main content

Clickhouse client for Good Kiwi

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

good_clickhouse-0.2.24-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: good_clickhouse-0.2.24.tar.gz
  • Upload date:
  • Size: 62.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for good_clickhouse-0.2.24.tar.gz
Algorithm Hash digest
SHA256 a2e0b739c4d1541da8948e92859d531ff56bf8ee95d210b08cf37b650f5f0eee
MD5 fb5aab56b5d503b039530d6a52a4eba8
BLAKE2b-256 c2153a70c3b0c24faf174118fdcbdaf3a1a00f1391d707053133535ed99c543a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for good_clickhouse-0.2.24-py3-none-any.whl
Algorithm Hash digest
SHA256 fabe88c6634b4ee2bc3a853c04b4766117b409dd38585e208ec5c0fa1a277f20
MD5 b4fa50c5a8e0ac4968979c1c6aad08bf
BLAKE2b-256 9d8ffaca2b10cfc82ec42fb58f9bd6a478fe1f47f02acb976a27239901de95b1

See more details on using hashes here.

Supported by

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