Skip to main content

Graphviz ER diagrams from a semql Catalog — cubes as nodes, joins as edges with crow's-foot arrowheads.

Project description

semql-erd

ER-diagram generator for semql catalogs. Walks the cubes and joins in a Catalog and emits a Graphviz DOT source (and convenience PNG/SVG when the graphviz Python bindings

  • system dot binary are available).

Useful when:

  • The catalog is past 10 cubes and reading the YAML/Python isn't enough to see the join shape at a glance.
  • A PR touches a Join and the reviewer wants a visual diff of the before / after graph.
  • Onboarding docs need a stable picture of what's in scope.

Install

pip install semql-erd            # DOT source only — no system deps
pip install "semql-erd[image]"   # + graphviz Python bindings
                                 #   (also needs the `dot` binary)

Quick start — DOT source

render_dot(catalog) is dependency-free: it produces a DOT-language string you can paste into any Graphviz renderer (Edotor is a quick web one).

from semql import Dialect, Catalog, Cube, Dimension, Join, Measure
from semql_erd import render_dot

orders = Cube(
    name="orders",
    dialect=Dialect.POSTGRES,
    table="orders",
    alias="o",
    measures=[Measure(name="revenue", sql="{o}.amount", agg="sum", unit="currency")],
    dimensions=[Dimension(name="region", sql="{o}.region", type="string")],
    joins=[Join(to="customers", relationship="many_to_one", on="{o}.cid = {c}.id")],
)
customers = Cube(
    name="customers",
    dialect=Dialect.POSTGRES,
    table="customers",
    alias="c",
    dimensions=[Dimension(name="name", sql="{c}.name", type="string")],
)

print(render_dot(Catalog([orders, customers])))

Quick start — PNG/SVG

from semql_erd import render_image

# Requires `pip install "semql-erd[image]"` AND the `dot` binary on PATH.
render_image(catalog, "catalog.png")  # PNG by default
render_image(catalog, "catalog.svg", format="svg")

Conventions

  • Nodes are cubes. The label is a Graphviz record showing the cube name (+ display_name suffix if set), the backend, and three field sections (measures, dimensions, time-dimensions).
  • Edges are Joins. Arrowhead shape encodes the relationship:
    • many_to_onecrow on the from-side, tee on the to-side
    • one_to_many → mirror of the above
    • one_to_onetee on both sides
  • Filtering mirrors the planner prompt: by default only cubes with expose_in_prompt=True (and non-META cubes) appear. Pass only_exposed=False for a full graph.
  • Layout defaults to rankdir="LR" (left-to-right). Pass rankdir="TB" for top-to-bottom.

CLI

python -m semql_erd path.to.module:catalog          # prints DOT to stdout
python -m semql_erd path.to.module:catalog out.svg  # writes a rendered image

Status

Early development. The DOT format is stable; record-section ordering and node ID naming may evolve.

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_erd-0.6.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

semql_erd-0.6.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file semql_erd-0.6.0.tar.gz.

File metadata

  • Download URL: semql_erd-0.6.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for semql_erd-0.6.0.tar.gz
Algorithm Hash digest
SHA256 ae70fb6e9540d1f996125d0d06b4642552c2a8f7d77a3119566b25952a2ed57b
MD5 d44ab7b1f413216cd99bcdf5c03fb43c
BLAKE2b-256 586ca8f693f0324511847965a22d4cc225af609833fa3550764ffd9e79e45403

See more details on using hashes here.

Provenance

The following attestation bundles were made for semql_erd-0.6.0.tar.gz:

Publisher: release.yml on semql-io/semql

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file semql_erd-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: semql_erd-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for semql_erd-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea7b940ef7f46206e15db405b60999e9ec2023236a72ceed0a26d8538a2bccc5
MD5 7ed5e5ea448c11d3f4d74c7a777dcd64
BLAKE2b-256 40b0e21df954b81b28f78869a525346f5ac0034f994d82356880f6024f362fe4

See more details on using hashes here.

Provenance

The following attestation bundles were made for semql_erd-0.6.0-py3-none-any.whl:

Publisher: release.yml on semql-io/semql

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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