Skip to main content

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 / countMeasure(agg="sum").
  • Columns ending in _idMeasure(agg="count_distinct") (the table's cardinality is usually interesting).
  • date / timestamp columns → TimeDimension.
  • Foreign keys → Join(relationship="many_to_one") plus the foreign-side Dimension(foreign_key=...).
  • Everything else → Dimension typed 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

semql_introspect-0.4.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

semql_introspect-0.4.0-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file semql_introspect-0.4.0.tar.gz.

File metadata

  • Download URL: semql_introspect-0.4.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

Hashes for semql_introspect-0.4.0.tar.gz
Algorithm Hash digest
SHA256 aaa8d814163df1ba403e722429f3b4cda50c24b8e779da7ef8c013a9ebc45e2d
MD5 f1c0e20839227e3df35b291f071f5e10
BLAKE2b-256 1da6d69368a06aab8c82356273f4d92d944ee677aa2027da17892e318d0445e7

See more details on using hashes here.

File details

Details for the file semql_introspect-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: semql_introspect-0.4.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

Hashes for semql_introspect-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f255c6d5148c6486b7c57ea824aa976373c1da9136f02c4a65dbff50a08e779
MD5 7d4c51624aa7e52e242cea01f1dbe570
BLAKE2b-256 4b2b603e3418cb219b71c189cc367ce8b83379148a4e178b648fe17e35cf9188

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page