clickhouse query
Project description
ClickHouse Query
!!! This repository is not complete, so the following codes may not work in current version. !!!
Clickhouse Query is a Python library for building complex ClickHouse queries by a fluent API and a set of functions.
Installation
pip install clickhouse-query
Usage
!!! This repository is not complete, so the following codes may not work in current version. !!!
import clickhouse_query as ch
q = (
ch.QuerySet()
.from_("my_table")
.prewhere(date__year__gte="2024")
.select(count=ch.Count())
.limit(10)
)
sql, sql_params = ch.get_sql(q)
# sql = 'SELECT count() AS count FROM click PREWHERE (greaterOrEquals(toYear(date), %(__U_1)s)) LIMIT %(__U_2)f'
# sql_params = {'__U_1': 2024, '__U_2': 10}
data = q.execute()
# data = [{'count': 100}]
Custom Functions
If there is not a function that you need, you can easily create it by extending the Function
class. like this:
class MyFunction(ch.Function):
function = "my_function"
Custom Aggregation Functions
If there is not a aggregation function that you need, you can easily create it by extending the AggregationFunction
class. like this:
class MyAggregationFunction(ch.AggregationFunction):
function = "my_aggregation_function"
License
This project is licensed under the MIT License - see the LICENSE file for details
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
Built Distribution
Hashes for clickhouse_query-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a077db6f7a709d50f0c04916c1bf1e895b4b1fbd280fb428ec301b5de795440 |
|
MD5 | 713fe7f9343d83500d9c754145d105fb |
|
BLAKE2b-256 | b1c584487ab1cc7fa229fe6edd4e63afbe62e556a9c391821182e49e2d5989e3 |