This release is a pre-release and may not be stable for production use.
hypequery for Python
A code-first semantic layer for ClickHouse. Define dimensions, measures and tenant rules once in Python, query them by name, serve them from FastAPI, Django or Flask, and reuse the same definitions from React and AI agents.
- No metrics service. It is a library. Definitions live in your codebase and queries run in your process, on your ClickHouse.
- Typed, validated queries. Requests are checked against the dataset before any SQL is generated, and the SQL is parameterized.
- Multi-tenant by default. Declare
tenant_keyonce and every query is scoped to the caller's tenant. - One definition, every surface. Rows, pandas, polars or Arrow in Python; authenticated HTTP endpoints; generated React hooks; governed MCP tools for agents.
Install
pip install "hypequery[clickhouse]"
Python 3.11 or later. Extras: clickhouse-async, server, jwt, django,
flask, pandas, polars, arrow, and chdb to run on embedded ClickHouse
with no server (Linux and macOS).
Define a dataset and query it
from hypequery.datasets import (
DatasetQuery,
ExecutionContext,
create_dataset_client,
dataset,
dimension,
filter,
measure,
order,
tenant,
)
from hypequery.execution import ClickHouseConnection, create_clickhouse_executor
orders = dataset(
"orders",
source="orders",
tenant_key="tenant_id",
time_key="created_at",
dimensions={
"country": dimension.string(),
"status": dimension.string(),
"createdAt": dimension.timestamp(column="created_at"),
},
measures={
"revenue": measure.sum("amount"),
"orderCount": measure.count("id"),
},
)
analytics = create_dataset_client(
executor=create_clickhouse_executor(ClickHouseConnection.from_env()),
)
result = analytics.execute(
orders,
DatasetQuery(
dimensions=("country",),
measures=("revenue", "orderCount"),
filters=(filter.eq("status", "paid"),),
order_by=(order.desc("revenue"),),
limit=10,
),
context=ExecutionContext(tenant=tenant("org_123")),
)
print(result.data)
ClickHouseConnection.from_env() reads CLICKHOUSE_HOST, CLICKHOUSE_PORT,
CLICKHOUSE_DATABASE, CLICKHOUSE_USERNAME and CLICKHOUSE_PASSWORD, or a
single CLICKHOUSE_URL. Already have tables? hypequery init introspects your
schema and writes the dataset definitions for you.
Serve it over HTTP
The API is plain ASGI, so it mounts in FastAPI, Starlette or any ASGI app, and is served natively from Django and Flask. Every endpoint authenticates before reading the body and takes the tenant from the caller.
pip install "hypequery[clickhouse,jwt]" fastapi uvicorn
from fastapi import FastAPI
from hypequery.serve import HttpSecurity, create_api, jwt_strategy, to_asgi_app
api = create_api(
auth=jwt_strategy(
jwks_url="https://example.auth0.com/.well-known/jwks.json",
issuer="https://example.auth0.com/",
audience="https://api.example.com",
),
client=analytics,
datasets={"orders": orders},
security=HttpSecurity(allowed_hosts=("api.example.com",)),
)
app = FastAPI()
app.mount("/analytics", to_asgi_app(api))
POST /analytics/datasets/orders/query now runs the same validated, tenant-scoped
query as the Python call above. The same endpoints feed generated, type-safe React
hooks (@hypequery/react) and a governed MCP server that gives agents named
metrics instead of raw SQL:
pip install "hypequery[mcp]"
hypequery mcp app:api --print-config # paste into Claude or Cursor
Learn more
- Quick start
- Python CLI: guided setup from a live schema, with FastAPI, Django or Flask scaffolds
- FastAPI, Django, Flask
- DataFrames: pandas, polars and Arrow results
- React and MCP clients
- Changelog
- Source and issues
hypequery is Apache 2.0 licensed. The TypeScript edition, with a type-safe query builder, lives in the same repository and implements the same specifications.
Beta. The Python SDK is tested end to end from the installed package, but its APIs may still change before 1.0. Pin the version you deploy and report problems on GitHub.
Metadata
Release files for hypequery 0.1.0b5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hypequery-0.1.0b5.tar.gz | 1.2 MB | With provenance | Details for hypequery-0.1.0b5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hypequery-0.1.0b5-py3-none-any.whl | Python 3 | none | any | Details for hypequery-0.1.0b5-py3-none-any.whl |
Total release size: 1.9 MB
Release files / hypequery-0.1.0b5.tar.gz
| Download URL | hypequery-0.1.0b5.tar.gz |
|---|---|
| Size | 1.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
505a54da442bdf385e644a69174509b3858d271524d66a5a236ae7b94fe796d6
|
|
BLAKE2b-256 checksum How to use checksums |
d73250d41f236a36fb19f92a987d59f7b35569f777deb256ca44bb272d6391c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.
Transparency logRelease files / hypequery-0.1.0b5-py3-none-any.whl
| Download URL | hypequery-0.1.0b5-py3-none-any.whl |
|---|---|
| Size | 654.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2caae00aaf2a553a15344d0b48076eecf09ee61f927c9a067233ebf8b76abb25
|
|
BLAKE2b-256 checksum How to use checksums |
b9c826846f62594baa0793148a7852d5e10323e7d50642f273a431a2c12faa71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.
Transparency logSecurity for hypequery 0.1.0b5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for hypequery-0.1.0b5.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.