Skip to content

Latest commit

 

History

History
26 lines (17 loc) · 728 Bytes

README.md

File metadata and controls

26 lines (17 loc) · 728 Bytes

SQLAlchemy-Mermaid

Mostly a quick (and dirty) script to generate a mermaid erDiagram from SQLAlchemy metadata object

Usage

from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy_mermaid import create_mermaid_diagram

Base = declarative_base()

# Define tables here or import Base from somewhere else

mermaid_diagram = create_mermaid_diagram(Base)

code_block = "```mermaid\n"
code_block += mermaid_diagram
code_block += "```"

with open("example_result.md", "w", encoding="utf-8") as f:
    f.writelines(code_block)

Example result (after rendering in VSCode): example db diagram