Skip to main content

Draw Entity-Relationship Diagrams (ERD) with python.

Project description

graphviz-erd

Draw Entity Relationship Diagrams (ERD) with python and graphviz.

This code is built on top of the graphviz python package and provides methods to facilitate the declaration of blocks commonly used in ERD such as entities and attributes.

Example

We can draw diagrams like erd

using the code:

    gr = graphviz.Graph("ER", filename="erd", engine="dot", format="png")
    obj = ERD(gr)

    # node name and node label
    obj.entity("entity1", "entity 1")
    # the label is optional as it is in graphviz
    obj.attribute("attr")
    # new lines using the html notation
    obj.multivalue("multi", "multivalued<BR/>attribute")
    obj.key("key", "key attribute")
    obj.derived("derived")
    obj.weak_key("weak")

    obj.associative_entity("assoc", "associative<BR/>entity")

    obj.weak_entity("entity2", "weak entity 2")

    # draw relation between entities
    obj.relation("relationship", "entity1", "entity2", "(1,2)", "(2, 1)", "yes")

    # connect the attributes
    obj.gr.edges(
        [
            ("entity1", "attr"),
            ("entity1", "multi"),
            ("entity1", "key"),
            ("entity1", "weak"),
            ("entity1", "derived"),
        ]
    )

    obj.gr.view()

Instructions (Development)

Assuming a linux environment (Ubuntu), to develop inside a virtual environment using git hooks:

python3 -m venv .venv
source .venv/bin/activate
pip install wheel
pip install -r requirements.txt
pre-commit install

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

graphviz-erd-0.0.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

graphviz_erd-0.0.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file graphviz-erd-0.0.0.tar.gz.

File metadata

  • Download URL: graphviz-erd-0.0.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for graphviz-erd-0.0.0.tar.gz
Algorithm Hash digest
SHA256 be38d0347acdece38828042a72f74a993ad3c9a1192c015fa723862f0065a66d
MD5 de94cf19ce441484e079cc51bcb3592e
BLAKE2b-256 7131249a5d95d74179c4dd9abec5ea6295abeb73f462bfd7e40984344e70d170

See more details on using hashes here.

File details

Details for the file graphviz_erd-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: graphviz_erd-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for graphviz_erd-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ac380de6bdb7a75fc53919ad0a3329cca7a0ab6529397fe584f129969193759
MD5 ec29f37965733e52e831b42dd5e311d2
BLAKE2b-256 21ebdf0a70cfded6ab2f414236506407281640977e71459a8de16223145b3c1d

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