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 catalogues. Walks the
cubes and joins in a Catalog and emits a Graphviz
DOT source (and convenience PNG/SVG when the graphviz Python bindings
- system
dotbinary are available).
Useful when:
- The catalogue is past 10 cubes and reading the YAML/Python isn't enough to see the join shape at a glance.
- A PR touches a
Joinand 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 Backend, Catalog, Cube, Dimension, Join, Measure
from semql_erd import render_dot
orders = Cube(
name="orders",
backend=Backend.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",
backend=Backend.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_namesuffix if set), the backend, and three field sections (measures, dimensions, time-dimensions). - Edges are
Joins. Arrowhead shape encodes the relationship:many_to_one→crowon the from-side,teeon the to-sideone_to_many→ mirror of the aboveone_to_one→teeon both sides
- Filtering mirrors the planner prompt: by default only cubes with
expose_in_prompt=True(and non-META cubes) appear. Passonly_exposed=Falsefor a full graph. - Layout defaults to
rankdir="LR"(left-to-right). Passrankdir="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
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_erd-0.2.0.tar.gz.
File metadata
- Download URL: semql_erd-0.2.0.tar.gz
- Upload date:
- Size: 6.9 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 |
d35e67f23f1b4eccbef21bfbf2d723c7a7c6bbbc457e9e86fca500bf0c8533c5
|
|
| MD5 |
259f1d3cbcc1f143c54a29685cb23191
|
|
| BLAKE2b-256 |
895028eac5022a6564b4a7c82659d31cf15bfb42004ebf7688b2b605892390eb
|
File details
Details for the file semql_erd-0.2.0-py3-none-any.whl.
File metadata
- Download URL: semql_erd-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.9 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 |
8570981c3c2413cea11975181030da4be77e25a9f12c3ab3d0b88986a21d64b4
|
|
| MD5 |
7942046fe65a27d23ae8a8c05993950a
|
|
| BLAKE2b-256 |
76e743b61d43d8bd10159aeddba87ad7523b60b7806bf8150fb2e55e266c6d57
|