Bootstrap a semql Catalog from a live database — emits Python cube stubs from Information Schema with heuristic measure/dimension inference.
Project description
semql-introspect
Bootstrap a semql Catalog from a live database.
Reads Information Schema, emits Python Cube stubs with heuristic
measure / dimension / time-dimension inference and foreign-key derived
joins. Designed for greenfield adoption — a team with 200 tables can
generate the mechanical 80% of a catalog in seconds, then hand-edit
the heuristic guesses.
Use this for cold-start scaffolding. For ongoing drift detection
on a catalog you already have, see
semql-validate-db — it probes a live
database against an authored catalog and surfaces missing tables /
columns / join predicates that the compiler can't see at build time.
Install
pip install semql-introspect
Usage
import duckdb
from semql.model import Dialect
from semql_introspect import introspect_to_python
con = duckdb.connect("warehouse.db")
print(introspect_to_python(con, dialect=Dialect.DUCKDB, schema="main"))
Or via CLI:
semql-introspect --backend duckdb --schema main --conn "warehouse.db"
Heuristics
- Numeric columns named
amount/price/revenue/cost/total/value/qty/quantity/count→Measure(agg="sum"). - Columns ending in
_id→Measure(agg="count_distinct")(the table's cardinality is usually interesting). date/timestampcolumns →TimeDimension.- Foreign keys →
Join(relationship="many_to_one")plus the foreign-sideDimension(foreign_key=...). - Everything else →
Dimensiontyped by the column's SQL type.
Heuristic guesses get a # TODO: review comment so the diff makes the
inference choices reviewable.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file semql_introspect-0.5.0.tar.gz.
File metadata
- Download URL: semql_introspect-0.5.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad5e6c8d1a2f015ec2c09653f669915f0a179a6bd43184da159c77befcf85865
|
|
| MD5 |
d5c879c38461707f646876eee5a1089a
|
|
| BLAKE2b-256 |
d081382c14fc14f51fb786405a70576abec2e5d08a43c4358d8f13128a38c879
|
File details
Details for the file semql_introspect-0.5.0-py3-none-any.whl.
File metadata
- Download URL: semql_introspect-0.5.0-py3-none-any.whl
- Upload date:
- Size: 16.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b69fd9f8ffba200a8d93d7fae7e7228438f11dae611c302e52c5f4b4d45f26c8
|
|
| MD5 |
7879b7efe1b9fe6dc75b2ff9c98a0f59
|
|
| BLAKE2b-256 |
695b7fe206bcb3ef5a396a5ce400d12bc1a2f74bf20962dc3e47c30e8748de7f
|