https://github.com/namgold/dbdiagram2json
https://github.com/namgold/dbdiagram2json
convert dbdiagram export json python
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/namgold/dbdiagram2json
- Owner: namgold
- Created: 2019-10-24T08:54:25.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-14T08:50:53.000Z (over 5 years ago)
- Last Synced: 2025-01-11T17:22:51.964Z (5 months ago)
- Topics: convert, dbdiagram, export, json, python
- Language: Python
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dbdiagram2json
## Description
This tool is used for export [https://dbdiagram.io](https://dbdiagram.io/) diagrams to JSON format.
## Usage1. Copy diagrams from [https://dbdiagram.io](https://dbdiagram.io/) to *dbdiagram.input* file place at the root of project.
2. Run command:
> python main.py
3. Output has been generated to *dbdiagram.json*
### Example
In file **`dbdiagram.input`**:
```
Table Customer as cus {
ID CHAR(10) [primary key, increment]
NAME NVARCHAR(100) [not null]
DATE_OF_BIRTH DATE [null]
ACTIVE CHAR(1) [not null, default: "F"]
}Table Order as ord {
ID CHAR(10) [primary key]
CUS_ID CHAR(10) [ref: > cus.ID, not null]
ITEM_ID CHAR(10) [ref: > Item.ID, not null]
}Table Item {
ID CHAR(10) [primary key, increment]
NAME NVARCHAR(100) [not null]
}
```Will generate folowing **`dbdiagram.json`**:
```json
{
"Table": [
{
"name": "Customer",
"shortName": "cus",
"option": null,
"fields": [
{
"name": "ID",
"type": "CHAR(10)",
"options": {
"primary key": true,
"increment": true
}
},
{
"name": "NAME",
"type": "NVARCHAR(100)",
"options": {
"nullable": false
}
},
{
"name": "DATE_OF_BIRTH",
"type": "DATE",
"options": {
"nullable": true
}
},
{
"name": "ACTIVE",
"type": "CHAR(1)",
"options": {
"nullable": false,
"default": "F"
}
}
]
},
{
"name": "Order",
"shortName": "ord",
"option": null,
"fields": [
{
"name": "ID",
"type": "CHAR(10)",
"options": {
"primary key": true
}
},
{
"name": "CUS_ID",
"type": "CHAR(10)",
"options": {
"ref": {
"op": ">",
"table": "cus",
"column": "ID"
},
"nullable": false
}
},
{
"name": "ITEM_ID",
"type": "CHAR(10)",
"options": {
"ref": {
"op": ">",
"table": "Item",
"column": "ID"
},
"nullable": false
}
}
]
},
{
"name": "Item",
"shortName": null,
"option": null,
"fields": [
{
"name": "ID",
"type": "CHAR(10)",
"options": {
"primary key": true,
"increment": true
}
},
{
"name": "NAME",
"type": "NVARCHAR(100)",
"options": {
"nullable": false
}
}
]
}
]
}
```