Skip to main content

No project description provided

Project description

logo

Welcome to ERDot 👋

PyPI License: MIT

Creates Entity Relationship Diagrams from JSON code.

Installation

to install ERDot:

pip install ERDot

you may also need to install graphvis to be able to create images of the dot files generated.

CLI Usage

Usage: erdot [OPTIONS]

Options:
  -i, --inputFile TEXT   The input ERDJSON file (.json)  [required]
  -o, --outputFile TEXT  The graphvis dot file to write to (.dot)  (default: ERDotOutput.dot)
  --help                 Show this message and exit.

Note that after generating the .dot file, you will still need to output it to your desired format using graphvis. An example of how to do this:

erdot -i inputFile.erd.json 

dot ERDotOutput.dot -Tpng -o imageFile.png

ERDJSON format:

{
    "tables":{
        ...
    },
    "relations":[
        ...
    ],
    "rankAdjustments":"...",
    "label":"..."
}   

Every single one of these sections are required, however, if you dont need that specific feature (for example label or rankAdjustments), just leave the value blank

table:

Each table inside of the table section of the ERDJSON document is formated like this:

"TableName": {
      "*PrimaryKey": "Int(10)",
      "+ForeignKey": "Int(10)",
      "RandomData": "Char(70)"
    }

the general idea is that the key is the column name, and the value is the type.

you will also notice the * and + next to the column names, these indicate primary and foriegn keys respectively. You can combine two of these together into a primary foreign key, just by putting both a * and a + next to the name.

relations:

each element in the relations array of the ERDJSON document is formatted like this:

"TableOne:PrimaryKey 1--* TableTwo:ForeignKey"

There are three elements that make up the relation string, (1) the left hand side, (2) the cardinality indicator, and (3) the right hand side.

Left and Right hand side:

The sides of the relation string consist of two elements, separated by a :. the text before the : indicates what table it is in, and the text after the : indicates what specific column it should use to link. (note how you dont include the + or * in the specific column text).

Cardinality indicator:

Each relationship must have two of these cardinalities in the indicator, separated by --:

Cardinality    Syntax
0 or 1         ?
exactly 1      1
0 or more      *
1 or more      +

So for example, the following defines a relationship between Person's PersonID primary key and BirthPlace's PersonID foreign key that reads "every person has exactly one birth place, linked together using PersonID":

Person:PersonID *--1 BirthPlace:PersonID

rankAdjustments

applies graphvis' rank adjustments to adjust where the tables appear in the final image. (note that it is only one string)

{ rank=min; TableOne Tabletwo }; // sets TableOne and TableTwo to be in the minimum rank (left)
{ rank=same; TableThree TableFour }; // sets TableThree and TableFour to be in the same rank
{ rank=max; TableFive }; // sets TableFive to be in the maximum rank (right)

Label

a string that sets what label will be drawn on top of the ERD, think of it like the title of the ERD.

Example ERDJSON:

{
    "tables":{
        "Person":{
            "*name":"char()",
            "height":"int()",
            "weight":"int()",
            "birthDate":"date()",
            "birthPlaceID":"int()"
        },
        "BirthPlace":{
            "*id":"int()",
            "birthCity":"char()",
            "birthState":"char()",
            "birthCountry":"char()"
        }
    },
    "relations":[
        "Person:birthPlaceID *--1 BirthPlace:id"
    ],
    "rankAdjustments":"",
    "label":""
}

which then creates this image:

logo

Author

👤 Darcy Lugt-Falk

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator

Project details


Download files

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

Files for ERDot, version 1.3.0
Filename, size File type Python version Upload date Hashes
Filename, size ERDot-1.3.0-py3-none-any.whl (54.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size ERDot-1.3.0.tar.gz (52.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page