db-diagram
This package provides a CLI and library for generating Mermaid Entity Relationship Diagrams based on an existing database connection URL and/or SQLAlchemy metadata.
Installation
You can install db-diagram
with pip:
pip3 install db-diagram
You will also need to have libraries installed for the SQLAlchemy dialect corresponding to your database, unless you are using MySQL/MariaDB or SQLite. For convenience, installation extras are defined for a handful of dialects:
pip3 install 'db-diagram[postgresql]'
pip3 install 'db-diagram[snowflake]'
pip3 install 'db-diagram[databricks]'
Usage
You can utilize db-diagram
as a
CLI (from a shell or command prompt),
or as a python library
(from db_diagram import write_markdown
).
The CLI will be more convenient under most circumstances, however
if you want to generate diagrams from SQLAlchemy metadata
rather than
a connection URL, such as you might for a
SQLAlchemy ORM,
you will want to use db_diagram
as a python library.
Pease refer to these examples
for reference concerning output.