Giter Site home page Giter Site logo

erd-render's Introduction

ER Diagram Render

(Diagram source code located at ./tests/property.py)

This is a package that lets you declare entity-relation diagrams programmatically and render them with graphviz.

Requisites:

  • graphviz distributable
  • graphviz Python package

How to install:

  1. Clone this repository
  2. Open a terminal at the root of the repository
  3. Execute the following:
  4. pip install .
  5. This package is installed

Quick start:

from erd_render import quick_entity, Relation, COUNT, render_chen

# quick_entity is a helper function that helps you declare Entities quickly
staff = quick_entity(
    # declare the name first
    "Staff",
    [
        # then give a list of attributes
        # see documentation for erd_render.modules.helpers#parse_attribute for more info
        "*id",  # "*" prefix means it is a key attribute
        "name: firstName lastName",  # ":" means this is a composite attribute, subattributes are space-separated
        "addresses[]",  # "[]" postfix means it is a multi-value attribute
        "salary",
    ],
)

project = quick_entity(
    "Project",
    [
        "*id",
        "name",
    ],
)

rel = Relation(
    # give tuples for each entity in the relationship
    (staff, COUNT.AT_LEAST_ONE),
    (project, 1),  # assume each staff must work on exactly 1 project at any time
    name="worksOn",
)

# render the diagram, default output path is `graph.gv.pdf`
render_chen(
    [staff, project],
    [rel],
)

See ./tests for more code and diagram examples.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.