Repository navigation
Home
SchemaGuru is an open-source (MIT) Python library that discovers, measures and explains a data warehouse so an AI agent can query it without guessing. It reads the catalog, measures facts such as how well two columns really join, drafts meaning with an optional LLM, lets people correct it in YAML, and serves a small question-scoped view to the agent. This wiki explains why it exists, how it is built, what every component does and how to use it, in plain language.
An agent that writes SQL against a warehouse has to know things the table names do not tell it: which column really joins to which, what values a status column actually holds, which rows are soft-deleted, which join path multiplies rows. When it guesses wrong it does not get an error. It gets a plausible, wrong number. SchemaGuru gives the agent that knowledge, and it says where every piece came from (a catalog, a measurement, a person, or an LLM draft) so nothing unchecked passes as checked. The longer story is on Why-Schema-Intelligence.
import schemaguru as sg
guru = sg.Guru.connect("duckdb:///shop.duckdb") # crawls the catalog on first use (metadata only)
print(guru.context("monthly revenue by customer segment"))Guru.connect opens the warehouse (SchemaGuru only ever reads from it), crawls the catalog into a local SQLite file
(./.schemaguru/default.db) when that file is empty, and context() returns the slice of the
warehouse relevant to the question, fitted to a token budget (4,000 by default). Asking a question
never spends warehouse money: tables it touches for the first time are only queued for
measurement (see Measurement).
| If you want to... | Read |
|---|---|
| understand the idea | Why-Schema-Intelligence, Concepts |
| see how the pieces fit | Architecture |
| connect your warehouse | the Warehouse-* guides in the sidebar, then Catalog-and-Crawl
|
| plug it into an agent | Agent-Integration |
| correct or add knowledge by hand | Overlays |
| run it from a shell or CI | CLI, Refresh-and-Drift |
| tune it | Configuration, Scale-and-Cost |
| add a warehouse, store, detector... | the Extending-* pages |
| know what is safe | Security, PII-and-Sampling-Policy |
SchemaGuru is at version 0.1.0 (alpha). Everything described in this wiki exists on main
unless the page says otherwise. Two things matter for what you can do today:
-
Measurement needs FactLang. SchemaGuru never writes measurement SQL itself; every number
comes from FactLang claims and primitives. The measurement
capabilities (
Checker.measure, sampling, join snippets, filter parsing) come with FactLang 0.1.4 or later, installed with SchemaGuru; with an older FactLang,measure()reports diagnosticSG304instead of measuring.schemaguru doctorshows which FactLang capabilities are present. The worked examples in this wiki were generated with the test suite's stand-in backend (reproducible byte for byte), and each one says so. -
Server mode and the Postgres store are optional extras.
schemaguru serve(extraserver) andPostgresStore(extrapostgres-store) are for shared deployments; see Server and Store.
Every example in this wiki uses one small, generic online shop: customers, orders,
order_items, products, payments, events, accounts, users, sessions. The same shop is
the test fixture in the repository
(tests/fixtures/shop), and
it is full of deliberate traps: an enum with case drift, dates stored as text, a soft-delete flag
that is TRUE or NULL but never FALSE, a thin-but-correct join, a broken join, and a hub table
that multiplies rows.
- Concepts - the vocabulary used everywhere else
- Architecture - the layers and the data flow, with diagrams
- FAQ - short answers to common questions
- Glossary - every term in one place
SchemaGuru is open source under the MIT License, Copyright (c) 2026 Rupak Chakraborty · Repository · Issues · This wiki is generated from docs/wiki/; edit it there, not here.
Start here
Components
- Catalog and Crawl
- Store
- Measurement
- Sampling
- Join Graph
- Path Search and Hub Guard
- Waypoint Rules
- Drafting
- PII and Sampling Policy
- Overlays
- Scoping
- Rendering
- Refresh and Drift
- Feedback and Guard
- Server
- Agent Integration
Using it
Warehouses
- BigQuery
- Snowflake
- Redshift
- Databricks
- PostgreSQL
- DuckDB
- ClickHouse
- SQL Server / Synapse
- Oracle
- Trino
- MySQL / MariaDB
Extending
- CatalogReader
- Store
- Retriever and Embedder
- TokenCounter
- LLMProvider
- PII Detector
- FailureClassifier
- FactKind
- Profile and Format
- ChangeClassifier
- JoinCandidateSource (planned)
- Authenticator
Project