Skip to content

heiskane/sqlalchemy_mermaid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Create mermaid erDiagram from SQLAlchemy metadata

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages