jts_erd: Create an ERD from JSON-table-schemas¶
jts_erd creates an ERD (entity-relationship diagram).
It requires an extension of a json-table-schema as input.
Depends on pygraphviz.
Introduction¶
For now please look at these slides: 20150927_talk.pdf
TL;DR Generate an entyty-relationship diagram for a schema given as JSON-table-schema.
Example of a resulting ERD:

Installation¶
Install graphviz and build tools:
aptitude install pkg-config build-essential graphviz libgraphviz-dev
You will need at least PyGraphviz 1.3.1 when using python3.
Currently (as of version 1.3.1 of pygraphviz) on at least debian and ubuntu you need special install options due to a bug (https://github.com/pygraphviz/pygraphviz/issues/71):
pip3 install pygraphviz --install-option="--include-path=/usr/include/graphviz" --install-option="--library-path=/usr/lib/graphviz/"
(gcc still throws a warning.)
Prepare a virtualenv with python3:
mkdir jts_erd
cd jts_erd
virtualenv -p python3
source bin/activate
In the virtualenv root dir:
git clone https://github.com/iburadempa/jts_erd.git
Usage examples¶
The main function jts_erd.get_graph()
creates a graphviz graph
from a (JSON-decoded) JSON-table-schema. An accompanying function,
jts_erd.save_svg()
, renders a graph in SVG format and saves it.
For examples look at the examples directory, https://github.com/iburadempa/jts_erd/tree/master/examples
API¶
jts_erd¶
Generate an entity-relationship diagram from an extended JSON table schema.
JSON table schema is a simple schema for describing the structure of tabular data. It can be extended to allow for a comprehensive representation of an SQL relational database schema.
Starting from such a description this python module generates visualizations of the database schema using graphviz via PyGraphviz.
-
jts_erd.jts_erd.
get_graph
(json_database_schema, **options)[source]¶ Create and return a graph from the given json_database_schema.
All keys from
options_defaults
are allowed in kwargs.
-
jts_erd.jts_erd.
options_defaults
= {'fontsize_label': 6, 'fontsize': 8, 'display_indexes': True, 'edge_thickness': 1.0, 'html_color_default': '#ccff99', 'fontsize_title': 10, 'rankdir': 'LR', 'bgcolor_indexes': '#ccccff', 'html_color_highlight': '#33cc99', 'display_crowfoots': True, 'display_columns': True, 'omit_isolated_tables': False, 'fontname': 'Helvetica'}¶ Options and their default values.
Options:
- html_color_default
- html_color_highlight
- fontname
- fontsize
- fontsize_title
- fontsize_label
- bgcolor_indexes
- rankdir: ‘LR’ or ‘RL’; whether dependent tables appear on the right (left) hand side
- edge_thickness
- display_columns: bool
- display_indexes: bool
- display_crowfoots: bool
- omit_isolated_tables: bool