Skip to content

Repository files navigation

erdalchemy

erdalchemy is an interactive ERD visualizer for SQLAlchemy 2.0 models. Point it at your DeclarativeBase and get a diagram, no manual configuration.

preview

  • Drag-and-drop interactive HTML, with hover highlighting
  • Three layouts: hierarchical layered (default), force-directed, and star
  • Orthogonal edge routing that follows foreign keys without cutting across cards
  • Regex filtering to focus large schemas (include/exclude tables and columns)
  • Export to HTML, SVG, PNG, and PDF
  • Built-in themes and per-table color overrides
  • Multi-schema support with cross-schema FKs
  • Zero dependencies beyond SQLAlchemy

Install

pip install erdalchemy

PNG and PDF export need an optional dependency:

pip install "erdalchemy[all]"

Quick start

from sqlalchemy_erd import generate_erd
from myapp.models import Base

generate_erd(Base, output="erd.html")

Or from the command line:

sqlalchemy-erd myapp.models:Base --format svg --output erd.svg

Layouts

Layout When to use
layered (default) General purpose. Ranks tables into columns by FK direction; cards never overlap. Best for large or wide schemas.
force Small, highly-connected graphs where an organic shape reads better.
star Star/snowflake and ETL schemas, or many disconnected tables.
generate_erd(Base, output="erd.html", layout="layered")

Documentation

Full reference (every CLI flag, the Python API, themes, layout tuning, card sizing, and supported column types) lives in docs/reference.md.

Examples

See examples/ for ready-to-run schemas:

Acknowledgments

Inspired by eralchemy2 (originally eralchemy), which pioneered generating ER diagrams from SQLAlchemy models. erdalchemy reimagines the idea with a self-contained, interactive, dependency-free renderer.

License

MIT

About

Interactive ERD visualizer for SQLAlchemy 2.0 models

Topics

Resources

Code of conduct

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages