SchemaGuru
Schema intelligence for AI agents on data warehouses. SchemaGuru crawls a warehouse's catalog, measures what really joins and which values really occur, refuses join paths that multiply rows, lets people correct it in reviewable YAML, and hands an agent a question-scoped, token-budgeted view of all of it: as prompt text, tool calls, an MCP server or framework adapters.
Why
An agent that writes SQL against a warehouse knows what the names tell it, and names mislead.
A join through a hub table multiplies rows; a soft-delete flag is TRUE or NULL but never
FALSE, so WHERE NOT is_deleted drops every live row; an enum drifted in case, so
status = 'paid' misses part of the paid orders. None of these raises an error: each returns
a plausible, wrong number. SchemaGuru measures these facts in the warehouse and puts them in
front of the agent, each labelled with where it came from.
Install
pip install schemaguru # core: FactLang + PyYAML
pip install 'schemaguru[duckdb]' # plus a warehouse driver (one extra per warehouse)
Python 3.10 to 3.13. Every warehouse driver, LLM provider and agent framework is an optional extra:
| Extra | Adds | Extra | Adds |
|---|---|---|---|
bigquery |
google-cloud-bigquery | anthropic |
Anthropic drafting provider |
snowflake |
snowflake-connector-python | openai |
OpenAI-compatible drafting provider |
redshift |
redshift-connector | mcp |
MCP server (stdio; HTTP also needs the server extra) |
databricks |
databricks-sql-connector | server |
HTTP server (Starlette, uvicorn) |
postgres |
psycopg 3 | langchain |
LangChain tools and retriever |
duckdb |
duckdb | llamaindex |
LlamaIndex tools |
clickhouse |
clickhouse-connect | openai-agents |
OpenAI Agents SDK tools |
mssql |
pyodbc (SQL Server, Synapse) | embeddings |
numpy (embedding retriever) |
oracle |
oracledb | tiktoken |
tiktoken token counter |
trino |
trino | postgres-store |
Postgres knowledge store (teams, server) |
mysql |
PyMySQL (MySQL, MariaDB) | all |
everything above |
Quickstart
import schemaguru as sg
guru = sg.Guru.connect("duckdb:///warehouse.duckdb")
print(guru.context("monthly revenue by customer segment"))
connect crawls the catalog on first use (metadata only) into a local store,
./.schemaguru/default.db. context returns the tables the question needs, with what is
known about them. Nothing has been measured yet, and the view says so. Measure, then ask
again:
guru.measure(all=True) # within the default budget; large tables are sampled and labelled
print(guru.context("monthly revenue by customer segment"))
path = guru.handle_tool_call("find_join_path", {"from": "orders", "to": "customers"})
print(path["text"]) # the same JSON tool an agent calls
guru.close()
The same from a terminal:
schemaguru crawl --url duckdb:///warehouse.duckdb
schemaguru measure --all --url duckdb:///warehouse.duckdb
schemaguru context "monthly revenue by customer segment"
Other warehouses connect by URL (snowflake://…, postgresql://…) or through the
connection a host already holds: sg.Guru(connector=conn) accepts a DB-API connection, a
SQLAlchemy engine, a BigQuery client or a plain execute(sql) function.
Features
| Feature | What it does |
|---|---|
| Catalog crawl | metadata only; paged, resumable and incremental; include/exclude globs; billed metadata bytes reported and capped (Budget.crawl_bytes) |
| Measurement | join match in both directions, fan-out, uniqueness, null rates, observed enum values, freshness; every number carries its method and date; budgeted per probe and per period; large tables sampled by key hash and labelled ESTIMATED, never cut with LIMIT |
| Join graph | measured and declared edges; path search returns thin joins labelled and refuses broken ones and row-multiplying hub pivots |
| Human overlays | reviewable YAML for descriptions, enums, soft-delete rules, join recipes and waivers; humans always win over drafts; dbt manifests import |
| LLM drafting | optional descriptions and pitfalls from Anthropic or OpenAI-compatible models, checked against measured facts and accepted through review |
| Scoped views | a question-scoped, token-budgeted view per agent role, as text, Markdown or JSON; byte-deterministic, with fingerprints for prompt-drift checks in CI |
| Agent surface | JSON tool specs and a dispatcher; an MCP server over stdio and streamable HTTP; LangChain, LlamaIndex, OpenAI Agents and Anthropic adapters |
| Refresh and drift | re-crawl, re-measure, diff against the previous snapshot and classify each change; exit codes for CI |
| Server | optional HTTP service over a shared Postgres store, with bearer tokens and one refresh at a time across replicas |
Every statement carries its provenance (catalog, declared, measured, drafted or human). Unknown is shown as unknown, never as 0 or 100%.
Privacy defaults
- Values reach an LLM masked by default: anything that looks personal (emails, phones,
IBANs, cards, IPs, UUIDs, long hex strings, secrets, names, addresses, free text) is replaced
by its shape, such as
<email>.rawis an explicit opt-in, andnonesends no values at all. The mode can be set per table glob (case-insensitive; on a tie the most restrictive wins). - Only the top values of low-cardinality columns and a few example values per column are read, never whole rows. Raw samples are not stored unless you opt in.
- A final sweep masks anything personal or credential-shaped in every outbound payload, and error messages are scrubbed of connection credentials on every surface.
- SchemaGuru never writes to a warehouse. An agent's question spends warehouse money only
when you allow it (
Config.measure_on_demand,Config.agent_checks).
Supported warehouses
| Warehouse | Status |
|---|---|
| DuckDB, PostgreSQL, MySQL / MariaDB, ClickHouse, SQL Server, Trino | catalog readers tested against real engines in CI (SQL Server 2022) |
| Azure Synapse | supported through the T-SQL reader; not CI-tested |
| BigQuery, Snowflake, Redshift, Databricks, Oracle | built from the documented system views and tested on recorded metadata; not yet validated against live accounts |
A warehouse that is not listed needs a custom catalog reader.
Built on FactLang
SchemaGuru writes no measurement SQL. It states what it wants to know as
FactLang measurements and claims; FactLang renders
dialect-correct SQL, runs it and reports the evidence. FactLang (factlang>=0.1.2,<0.2) is
installed with SchemaGuru.
Documentation
- Documentation site: https://rupakc.github.io/schemaguru/ (guides, API reference, interactive demo)
- Wiki: https://github.com/rupakc/schemaguru/wiki (concepts, each component, warehouse guides, extending, FAQ)
- Changelog: CHANGELOG.md
Contributing
Contributions are welcome. CONTRIBUTING.md has the setup, the checks CI runs and the project rules; SECURITY.md says how to report a vulnerability.
License
MIT. Copyright (c) 2026 Rupak Chakraborty. See LICENSE.
Metadata
Release files for schemaguru 0.1.0
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 |
|---|---|---|---|---|
| schemaguru-0.1.0.tar.gz | 582.6 kB | With provenance | Details for schemaguru-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| schemaguru-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for schemaguru-0.1.0-py3-none-any.whl |
Total release size: 966.4 kB
Release files / schemaguru-0.1.0.tar.gz
| Download URL | schemaguru-0.1.0.tar.gz |
|---|---|
| Size | 582.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d3283ade7eae1d963518c2bc091a807cbd15733004219d7d839a0afb7d3d98b
|
|
BLAKE2b-256 checksum How to use checksums |
c193a231cbb430ce9c7dfcbb666edc99e590371d5416a391c49cab11697585ee
|
| 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 25, 2026.
Transparency logRelease files / schemaguru-0.1.0-py3-none-any.whl
| Download URL | schemaguru-0.1.0-py3-none-any.whl |
|---|---|
| Size | 383.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e982cefb767138b8737f42c7510b1fc77b8f2bf502103f1662bf248294055b20
|
|
BLAKE2b-256 checksum How to use checksums |
caa6e58470ef9946529449f430de71bbb2a661c6b9b21077f6551d1037e2e386
|
| 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 25, 2026.
Transparency logSecurity for schemaguru 0.1.0
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 schemaguru-0.1.0.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 25, 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.