Skip to main content
Pre-release

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.

PyPI Python versions License Docs

  • 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_key once 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

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.0b6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hypequery 0.1.0b6
File Size Uploaded Provenance Actions
hypequery-0.1.0b6.tar.gz 1.3 MB With provenance Details for hypequery-0.1.0b6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hypequery 0.1.0b6
File Interpreter ABI Platform Actions
hypequery-0.1.0b6-py3-none-any.whl Python 3 none any Details for hypequery-0.1.0b6-py3-none-any.whl

Total release size: 2.0 MB

Release files / hypequery-0.1.0b6.tar.gz

Download URL hypequery-0.1.0b6.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
d78c620e8b67d1606ab09f042e844329be31fc6f77bd64fda1a047e8c6fe1ba4
BLAKE2b-256 checksum
How to use checksums
b5c1d31843f55c99363b35758c9c789ff5fbf423839bf75ba7e9e26318e537a2
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 log

Release files / hypequery-0.1.0b6-py3-none-any.whl

Download URL hypequery-0.1.0b6-py3-none-any.whl
Size 678.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16866ffe70d0a1960a3ce20c354bf3db210ca8e0686c476e642382cd0b4c81d5
BLAKE2b-256 checksum
How to use checksums
2422a4590c6a44fe82f6cfa120a10febc4dd44da3f1d540588f83e5054c17c23
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 log

Security for hypequery 0.1.0b6

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.

Select from 2 files

Attestation for hypequery-0.1.0b6.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 log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page