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

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

We also support D2 as an alternative output format.

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

Type annotations are formatted using the typenames library.

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 "erdantic @ git+https://github.com/drivendataorg/erdantic.git"

See pip's documentation for more on how to specify VCS dependencies.

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.2.0.tar.gz (920.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

erdantic-1.2.0-py3-none-any.whl (34.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: erdantic-1.2.0.tar.gz
  • Upload date:
  • Size: 920.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for erdantic-1.2.0.tar.gz
Algorithm Hash digest
SHA256 165979caf26984055e476d0201b24cdf1c5f38b60a6f141e82f9352a40d12b65
MD5 bd58f5b1a389269cbcfdad558894a6d0
BLAKE2b-256 6f175c9709349221b1a972b4470e735570eee3dd2e2ee0ed71f28fb0e8c0d79a

See more details on using hashes here.

Provenance

The following attestation bundles were made for erdantic-1.2.0.tar.gz:

Publisher: release.yml on drivendataorg/erdantic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: erdantic-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 34.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for erdantic-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c67adcf22150b77a24609734c7efc676f71824f8f5662fd21450ec1cdbe0a0c
MD5 156684740d76da00caa6403e7887b430
BLAKE2b-256 06eedc88399e2a872fd7ce5a192cfbcf8bd996574bb6c7470912c8c2fca20527

See more details on using hashes here.

Provenance

The following attestation bundles were made for erdantic-1.2.0-py3-none-any.whl:

Publisher: release.yml on drivendataorg/erdantic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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