Package: paracelsus
ParacelsusParacelsus generates Entity Relationship Diagrams by reading your SQLAlchemy models.ERDs can be injected into documentation asMermaid Diagrams.Paracelsus can be run in CICD to check that databases are up to date.ERDs can be created as files in eitherDotor Mermaid format.DOT files can be used to generate SVG or PNG files, or edited inGraphVizor other editors.UsageInstallationThe paracelsus package should be installed in the same environment as your code, as it will be reading your SQLAlchemy base class to generate the diagrams.pipinstallparacelsusBasic CLI UsageParacelsus is primarily a CLI application.paracelsus--helpIt has three commands:versionoutputs the version of the currently installedparacelsuscli.graphgenerates a graph and outputs it tostdout.injectinserts the graph into a markdown file.Importing ModelsSQLAlchemy models have to be imported before they are put into the model registry inside of the base class. This is similar to howAlembicneeds models to be imported in order to generate migrations.The--import-moduleflag can be used to import any python module, which presumably will include one or more SQLAlchemy models inside of it.paracelsusgraphexample_app.models.base:Base\--import-module"example_app.models.users"\--import-module"example_app.models.posts"\--import-module"example_app.models.comments"The:*modify can be used to specify that a wild card import should be used. Make sure to wrap the module name in quotes when using this to prevent shell expansion.paracelsusgraphexample_app.models.base:Base--import-module"example_app.models:*"This is equivalent to running this style of python import:fromexample_app.modelsimport*Generate Mermaid Diagramsparacelsus graph example_app.models.base:Base --import-module "example_app.models:*"erDiagram
 users {
  CHAR(32) id PK
  DATETIME created
  VARCHAR(100) display_name "nullable"
 }

 posts {
  CHAR(32) id PK
  CHAR(32) author FK
  TEXT content "nullable"
  DATETIME created
  BOOLEAN live "nullable"
 }

 comments {
  CHAR(32) id PK
  CHAR(32) author FK
  CHAR(32) post FK "nullable"
  TEXT content "nullable"
  DATETIME created
  BOOLEAN live "nullable"
 }

 users ||--o{ posts : author
 posts ||--o{ comments : post
 users ||--o{ comments : authorWhen run through a Mermaid viewer, such as the ones installed in the markdown viewers of many version control systems, this will turn into a graphic.erDiagram
 users {
  CHAR(32) id PK
  DATETIME created
  VARCHAR(100) display_name "nullable"
 }

 posts {
  CHAR(32) id PK
  CHAR(32) author FK
  TEXT content "nullable"
  DATETIME created
  BOOLEAN live "nullable"
 }

 comments {
  CHAR(32) id PK
  CHAR(32) author FK
  CHAR(32) post FK "nullable"
  TEXT content "nullable"
  DATETIME created
  BOOLEAN live "nullable"
 }

 users ||--o{ posts : author
 posts ||--o{ comments : post
 users ||--o{ comments : authorInject Mermaid DiagramsMermaid Diagrams and Markdown work extremely well together, and it's common to place diagrams inside of project documentation. Paracelsus can be used to inject diagrams directly into markdown configuration. It does so by looking for specific tags and placing a code block inside of them, replacing any existing content between the tags.## Schema<!-- BEGIN_SQLALCHEMY_DOCS -->

<!-- END_SQLALCHEMY_DOCS -->paracelsus inject db/README.md example_app.models.base:Base --import-module "example_app.models:*"The--checkflag can be used to see if the command would make any changes. If the file is already up to date then it will return a status code of0, otherwise it will return1if changes are needed. This is useful in CI/CD or precommit hook to enforce that documentation is always current.paracelsus inject db/README.md example_app.models.base:Base --import-module "example_app.models:*" --checkCreating ImagesGraphViz has a command line tool nameddotthat can be used to turndotgraphs into images.To create an SVG file:paracelsus graph example_app.models.base:Base --import-module "example_app.models:*" --format dot | dot -Tsvg > output.svgTo create a PNG file:paracelsus graph example_app.models.base:Base --import-module "example_app.models:*" --format dot | dot -Tpng > output.pngSponsorshipThis project is developed byRobert HafnerIf you find this project useful please consider sponsoring me using Github!