Repository navigation
Catalog and Crawl
The crawl reads the warehouse's own metadata (schemas, tables, columns, types, keys, comments, statistics) into the local store, without reading a single data row. It is paged, resumable after an interruption, incremental where the warehouse can say what changed, and its memory use does not grow with the number of tables. One reader per warehouse dialect turns system views into SchemaGuru objects; unknown values stay unknown.
guru = sg.Guru.connect("duckdb:///warehouse.duckdb", crawl=False)
report = guru.crawl(include=["shop.*"]) # include/exclude override the config
print(report)Guru.connect crawls automatically when the store holds no table yet (crawl=None, the default);
pass crawl=True to always crawl or crawl=False to never crawl on connect. A crawl is
metadata only, but it is still a set of queries against the warehouse (and billed on BigQuery),
so it is counted in the ledger.
Real output on the shop fixture (generated 2026-11-24 with SchemaGuru 0.1.0, DuckDB reader):
CrawlReport(tables_seen=14, tables_written=14, withdrawn=0, errors=[], queries=6, bytes_billed=None, bytes_billed_is_estimate=False, duration_s=0.018889292143285275)
bytes_billed=None means "this warehouse does not bill metadata queries by bytes", not zero.
-
list_catalogs()(may yield nothing; most readers work in one default catalog). -
list_schemas(catalog)in pages. -
list_tables(schema)in pages ofcrawl.page_sizetables (default 1,000). -
columns(tables)andconstraints(tables)in batches ofcrawl.column_batchtables (default 200), on a pool ofcrawl.workersthreads (default 4), each query capped atcrawl.timeout_s(default 60 s).
Each page and its checkpoint are written to the store in one transaction. If the crawl is interrupted (an error, Ctrl-C, a crash), the next crawl resumes from the checkpoint: schemas before the saved cursor are skipped and the schema in progress restarts at its saved page.
Memory stays flat. The names seen in this run live in a throw-away on-disk SQLite file, and the checkpoint is a small cursor, so memory is bounded by the page size and the number of schemas, never by the number of tables. The scale benchmark crawled 100,000 synthetic tables at about 9,600 tables per second with a peak memory of 45 MB (see Scale-and-Cost).
When a reader reports incremental=True in its capabilities, a later crawl re-reads only tables
changed since the last crawl that finished without errors, plus a cheap name-only listing per
schema to notice drops and restorations. Incremental mode is ignored when your include/exclude
scope changed since that crawl, because the old crawl's view of "everything" no longer matches.
A table that a complete listing of its schema no longer shows (or whose schema went out of scope)
is marked withdrawn_at. It is a soft delete: its facts and any human overlay about it are kept
and surface as drift in the next Refresh-and-Drift report. If the table comes back, it is
live again.
crawl.include and crawl.exclude are case-sensitive glob patterns matched against
schema.table and catalog.schema.table. An empty include allows everything; exclude always
wins. The defaults exclude system and scratch objects:
CrawlConfig().exclude
# ('information_schema.*', 'pg_catalog.*', 'sys.*', '*.*_staging*', '*.*tmp*')Excluded objects are never stored. An exclude pattern whose table part is exactly *
(sys.*) skips the whole schema without listing it.
A schema, page or batch that fails is recorded as diagnostic SG102 with its location and
skipped; the crawl continues, and CrawlReport.errors lists every skipped item. A crawl with
errors does not become the baseline for the next incremental crawl.
A CatalogReader turns one warehouse's system views into Schema, Table, Column and
Constraint objects. Shipped readers (sg.catalog.dialects()):
['bigquery', 'clickhouse', 'databricks', 'duckdb', 'mysql', 'oracle', 'postgres', 'redshift', 'snowflake', 'trino', 'tsql']
Each has a guide with permissions, cost and quirks: Warehouse-BigQuery, Warehouse-Snowflake, Warehouse-Redshift, Warehouse-Databricks, Warehouse-PostgreSQL, Warehouse-DuckDB, Warehouse-ClickHouse, Warehouse-TSQL, Warehouse-Oracle, Warehouse-Trino, Warehouse-MySQL.
How well each reader is tested:
- Validated against real engines in CI: PostgreSQL, MySQL, ClickHouse, SQL Server, Trino (service containers) and DuckDB.
-
Built from documented system-view shapes, not yet validated against live accounts:
BigQuery, Snowflake, Redshift, Databricks, Oracle. They are tested against recorded metadata
fixtures, and opt-in live tests exist (
tests/live/). Please report what you find.
Rules every reader follows:
-
Metadata only. System catalogs,
INFORMATION_SCHEMA,SHOWcommands. Never a data row. -
Bind parameters for every value. Readers write SQL with
?placeholders; the executor converts them to the driver's style. Identifiers that cannot be bound (a BigQuery project or region) are validated against a strict character set first. -
Read-only, checked. Every metadata statement passes
check_metadata_sqlfirst: a singleSELECT/WITH/SHOW/DESCRIBE, no;, no comments, no DML/DDL keyword, judged under several quoting conventions. A violation isSG104. -
Unknown is
None. A row count the warehouse does not report staysNone; it is never 0.
Guru.connect(url) opens the URL through FactLang's connect() when it is available (FactLang
0.1.0; most warehouses need SQLAlchemy and the warehouse's driver extra). Without it, duckdb://
URLs open through the DuckDB driver directly, and DuckDB files open read-only (a typo never
creates a new file). Any other URL then fails with SG106.
You can also bring your own connection and reader:
from schemaguru.catalog import DBAPIExecutor, reader_for
guru = sg.Guru(reader=reader_for("duckdb", DBAPIExecutor(conn)), dialect="duckdb", store="shop.db")DBAPIExecutor(connection, paramstyle="qmark") wraps any DB-API connection;
FactLangExecutor(connector) wraps a FactLang connector. Connection URLs are never shown in full
in errors, logs or repr: only scheme://host[:port] is shown, and anything that does not parse
cleanly becomes scheme://***.
- Store - where the crawl writes
- Extending-CatalogReader - add a warehouse
- Refresh-and-Drift - recrawling and what changed
- Scale-and-Cost - crawl cost on large warehouses
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