Mostly a quick (and dirty) script to generate a mermaid erDiagram from SQLAlchemy metadata object
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)