Skip to main content

Entity relationship diagrams for Python data model classes like Pydantic.

Project description

erdantic: Entity Relationship Diagrams

Docs Status PyPI conda-forge conda-forge feedstock tests codecov

[!NOTE] erdantic v1.0 has been released! See the changelog for more information.

erdantic is a simple tool for drawing entity relationship diagrams (ERDs) for Python data model classes. Diagrams are rendered using the venerable Graphviz library. Supported data modeling frameworks are:

You can use erdantic either as a convenient CLI or as a Python library. Great for adding a simple and clean data model reference to your documentation.

Example diagram created by erdantic

Installation

erdantic's graph modeling depends on pygraphviz and Graphviz, an open-source C library. If you are on Linux or macOS, the easiest way to install everything together is to use conda and conda-forge:

conda install erdantic -c conda-forge

If not using conda, Graphviz must be installed first (before you can install pygraphviz). For recommended options and installation troubleshooting, see the pygraphviz docs. Then to install erdantic and its Python dependencies from PyPI:

pip install erdantic

Development version

You can get the development version from GitHub with:

pip install git+https://github.com/drivendataorg/erdantic.git#egg=erdantic

Quick usage

First, make sure that the data model classes that you want to include in your diagram are importable. This means the code with your models should either be available on your sys.path or installed into the same virtual environment as erdantic.

The fastest way to produce a diagram like the above example is to use the erdantic CLI. Simply specify the full dotted import path to your model and an output file path. The rendered format is interpreted from the filename extension.

erdantic erdantic.examples.pydantic.Party -o diagram.png

You can also import the erdantic Python library. This lets you inspect the diagram data and potentially modify it. You will have greater ability to customize the diagram in Python.

import erdantic as erd
from erdantic.examples.pydantic import Party

# Easy one-liner
erd.draw(Party, out="diagram.png")

# Or create a diagram object that you can inspect and do stuff with
diagram = erd.create(Party)
list(diagram.models.keys())
#> [ 'erdantic.examples.pydantic.Adventurer',
#>   'erdantic.examples.pydantic.Party',
#>   'erdantic.examples.pydantic.Quest',
#>   'erdantic.examples.pydantic.QuestGiver']
diagram.draw("diagram.png")

Check out the "Usage Examples" section of our docs to see more.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

erdantic-1.0.5.tar.gz (813.5 kB view details)

Uploaded Source

Built Distribution

erdantic-1.0.5-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

Details for the file erdantic-1.0.5.tar.gz.

File metadata

  • Download URL: erdantic-1.0.5.tar.gz
  • Upload date:
  • Size: 813.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.20

File hashes

Hashes for erdantic-1.0.5.tar.gz
Algorithm Hash digest
SHA256 e35cc1babb37b8dc62fc220ce61a167afaebd11e391c6bd53882918a3b01644b
MD5 f5e062cbfde4e88ef9aafcc815040361
BLAKE2b-256 8dff30b37ea3aa78c84558d8042150adc653b2a6a9af2bde2785d37177646aca

See more details on using hashes here.

File details

Details for the file erdantic-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: erdantic-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 30.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.20

File hashes

Hashes for erdantic-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f9ae0016d5e6116e14cf11b75c6a1ead467d7a13adbea9632df102199e22499a
MD5 ea8321d0f50b8319e7cdbca55e2d46c3
BLAKE2b-256 cd5eeef0d436e53ca91dd5768ff5f7baa65bac8a27b90f94002c95b984556f5f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page