{"id":13658476,"url":"https://github.com/ehne/ERDot","last_synced_at":"2025-04-24T11:31:47.976Z","repository":{"id":37721985,"uuid":"275041381","full_name":"ehne/ERDot","owner":"ehne","description":"A python CLI script to create Entity Relationship Diagrams from JSON/YAML code.","archived":false,"fork":false,"pushed_at":"2024-01-29T15:26:37.000Z","size":162,"stargazers_count":73,"open_issues_count":6,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-02T14:39:25.116Z","etag":null,"topics":["dot","entity-relationship-diagram","erd","graphvis","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ehne.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"liberapay":"ehne"}},"created_at":"2020-06-26T00:23:04.000Z","updated_at":"2024-09-26T02:35:48.000Z","dependencies_parsed_at":"2024-04-09T17:57:20.083Z","dependency_job_id":"7f73c6cf-f488-4fbd-a338-97ddb0d41b28","html_url":"https://github.com/ehne/ERDot","commit_stats":{"total_commits":38,"total_committers":4,"mean_commits":9.5,"dds":"0.23684210526315785","last_synced_commit":"5975ff9d88c275605ba19d69a9b284f0118697b1"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehne%2FERDot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehne%2FERDot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehne%2FERDot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehne%2FERDot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ehne","download_url":"https://codeload.github.com/ehne/ERDot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223952507,"owners_count":17230900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dot","entity-relationship-diagram","erd","graphvis","python"],"created_at":"2024-08-02T05:00:59.885Z","updated_at":"2024-11-10T12:30:18.419Z","avatar_url":"https://github.com/ehne.png","language":"Python","funding_links":["https://liberapay.com/ehne"],"categories":["Python"],"sub_categories":[],"readme":"\u003cp\u003e\n  \u003cimg alt=\"logo\" src=\"https://github.com/ehne/ERDot/raw/master/logo.png\" align=\"center\"/\u003e\n\u003c/p\u003e\n\u003ch1 align=\"center\"\u003e\n  Welcome to ERDot 👋\n\u003c/h1\u003e\n\u003cp\u003e\n  \u003ca href=\"https://pypi.org/project/ERDot/\"\u003e\n    \u003cimg alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/ERDot?color=blue\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/ehne/ERDot/blob/master/LICENSE\"\u003e\n    \u003cimg alt=\"License: MIT\" src=\"https://img.shields.io/github/license/ehne/ERDot\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e Creates Entity Relationship Diagrams from JSON/YAML code.\n\n## Installation\nto install ERDot:\n\n```pip install ERDot```\n\nyou may also need to [install graphvis](https://graphviz.org/download/) to be able to create images of the dot files generated. If you don't want to install graphviz, you can copy the contents of the generated dot file into an [online grapviz viewer](https://edotor.net).\n\n## CLI Usage\n```bash\nUsage: erdot [OPTIONS] INPUTFILE\n\n  ERDot generates graphvis .dot files from the .json/.yml files INPUTFILE.\n\nOptions:\n  -o, --outputFile TEXT  The graphvis dot file to write (.dot)\n  -q, --quiet            Suppresses program information messages.\n  --help                 Show this message and exit.\n```\n\nNote that after generating the .dot file, you will still need to output it to your desired format using graphviz. An example of how to do this:\n\n```bash\n$ erdot example.erd.json \n\n$ dot example.dot -Tpng -o imageFile.png\n```\n\n(You could also copy and paste the contents of the .dot file into an [online graphviz viewer](https://edotor.net))\n\n## ERDJSON format:\n```json\n{\n    \"tables\":{\n        ...\n    },\n    \"relations\":[\n        ...\n    ],\n    \"rankAdjustments\":\"...\",\n    \"label\":\"...\"\n}   \n```\n\nEvery 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\n\n### table:\nEach table inside of the table section of the ERDJSON document is formated like this:\n\n```json\n\"TableName\": {\n      \"*PrimaryKey\": \"Int(10)\",\n      \"+ForeignKey\": \"Int(10)\",\n      \"RandomData\": \"Char(70)\"\n    }\n```\n\nthe general idea is that the key is the column name, and the value is the type.\n\nyou 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 (a composite key consisting of two foreign keys), just by putting both a `*` and a `+` next to the name.\n\n### relations:\neach element in the relations array of the ERDJSON document is formatted like this:\n\n```json\n\"TableOne:PrimaryKey 1--* TableTwo:ForeignKey\"\n```\n\nThere are three elements that make up the relation string, (1) the left hand side, (2) the cardinality indicator, and (3) the right hand side. \n\n#### Left and Right hand side:\nThe 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).\n\n#### Cardinality indicator:\nEach relationship must have two of these cardinalities in the indicator, separated by `--`:\n\n```\nCardinality    Syntax\n0 or 1         ?\nexactly 1      1\n0 or more      *\n1 or more      +\n```\n\nSo for example, the following defines a relationship between Person's birthplaceID foreign key and BirthPlace's ID primary key that reads \"every person has exactly one birth place, linked together using the birthplaceID\":\n\n```python\nPerson:birthplaceID *--1 BirthPlace:ID\n```\n\n### rankAdjustments\napplies graphvis' rank adjustments to adjust where the tables appear in the final image. (note that it is only one string)\n\n```js\n{ rank=min; TableOne Tabletwo }; // sets TableOne and TableTwo to be in the minimum rank (left)\n{ rank=same; TableThree TableFour }; // sets TableThree and TableFour to be in the same rank\n{ rank=max; TableFive }; // sets TableFive to be in the maximum rank (right)\n```\n\n### Label\na string that sets what label will be drawn on top of the ERD, think of it like the title of the ERD.\n\n## Example ERDJSON:\n```json\n{\n    \"tables\":{\n        \"Person\":{\n            \"*name\":\"char()\",\n            \"height\":\"int()\",\n            \"weight\":\"int()\",\n            \"birthDate\":\"date()\",\n            \"+birthPlaceID\":\"int()\"\n        },\n        \"BirthPlace\":{\n            \"*id\":\"int()\",\n            \"birthCity\":\"char()\",\n            \"birthState\":\"char()\",\n            \"birthCountry\":\"char()\"\n        }\n    },\n    \"relations\":[\n        \"Person:birthPlaceID *--1 BirthPlace:id\"\n    ],\n    \"rankAdjustments\":\"\",\n    \"label\":\"\"\n}\n```\n\nwhich then creates this image:\n\n\u003cimg alt=\"logo\" src=\"https://github.com/ehne/ERDot/raw/master/example/example.png\" align=\"center\"/\u003e\n\nThe ERDYAML of the same image would look like:\n\n```yaml\ntables:\n  Person:\n    \"*name\": char()\n    height: int()\n    weight: int()\n    birthDate: date()\n    \"+birthPlaceID\": int()\n  BirthPlace:\n    \"*id\": int()\n    birthCity: char()\n    birthState: char()\n    birthCountry: char()\nrelations:\n- Person:birthPlaceID *--1 BirthPlace:id\nrankAdjustments: ''\nlabel: ''\n```\n\n## Author\n\n👤 **ehne**\n\n* Github: [@ehne](https://github.com/ehne)\n\n## Show your support\n\nGive a ⭐️ if this project helped you!\n\n***\n_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehne%2FERDot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fehne%2FERDot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehne%2FERDot/lists"}