To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 71bb8b1a authored by Xuqian Yan's avatar Xuqian Yan
Browse files

Included nexus-e-database.md, automatically generated with a plugin in MySQL Workbench

parent 35a402b6
The MIT License (MIT)
Copyright (c) 2015 Hieu Le Trung
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# MySQL Workbench Model Document Generation
A Python script to generate documentation from MySQL Workbench ERR diagram. This README file is adpated based on the README.md from [this repository](https://github.com/letrunghieu/mysql-workbench-plugin-doc-generating/releases/tag/1.0.2) (retrieved on Apriil 16, 2021). The codes in mysql-workbench-plugin-doc-generating.py is slightly adjusted.
## Installation
* Open the MySQL Workbench
* Navigate to menu **Scripting** > **Install Plugin/Module...**
* Browse and select the extracted `mysql-workbench-plugin-doc-generating.py` file in this folder
* Restart the Workbench
## Usage
An example output of the Nexus-e database can be found at [nexus-e-database.md](nexus-e-database.md).
### Generate documentation from ERR digram
* Open the ERR digram
* Navigate to menu **Tools** > **Utilities** > **Generate Documentation (Markdown)**
* When you see the status bar text changed to *Documentation generated into the clipboard. Paste it to your editor.*, Paste (<kbd>Ctrl</kbd> + <kbd>V</kbd> in most Linux/Window applications) to your editor and save as a new file.
* Name the new file as `nexus-e-database.md` and store it in the folder **docs/sources**.
### Generate ERR digram from physical database
In case that you do not have the ERR diagram, you have to create a diagram from your physical database first. Don't worry, MySQL Workbench has a greate tool to do this for you called **Reverse Engineer**.
* Open Workbench
* Navigate to menu **Database** > **Reverse Engineer...**
* Choose the connection, **Next**
* Wait and **Next**
* Select the datbase you want to create ERR diagram from, **Next**
* Wait and **Next**
* Select tables that you want to include in the ERR diagram, **Execute>**
* Wait and **Next**
* **Finish**
You have a new ERR diagram, you can generate the documentation from this diagram as the previous step.
After that, you can convert the output Markdown document into any format that you want.
## License
This script is released under the MIT license.
# MySQL Workbench Plugin
# <description>
# Written in MySQL Workbench 6.3.4
from wb import *
import grt
import mforms
ModuleInfo = DefineModule("ModelDocumentation", author="Hieu Le", version="1.0.0", description="Generate Markdown documentation from a model")
# This plugin takes no arguments
@ModuleInfo.plugin("info.hieule.wb.documentation", caption="Generate documentation (Markdown)", description="description", input=[wbinputs.currentDiagram()], pluginMenu="Utilities")
@ModuleInfo.export(grt.INT, grt.classes.db_Catalog)
def documentation(diagram):
text = "# Schema documentation\n\n"
text += "Generated by [MySQL Workbench Model Documentation plugin](https://github.com/letrunghieu/mysql-workbench-plugin-doc-generating) - Copyright (c) 2015 Hieu Le\n\n";
for figure in diagram.figures:
if hasattr(figure, "table") and figure.table:
text += writeTableDoc(figure.table)
mforms.Utilities.set_clipboard_text(text)
mforms.App.get().set_status_text("Documentation generated into the clipboard. Paste it to your editor.")
print "Documentation is copied to the clipboard."
return 0
def writeTableDoc(table):
text = "## Table: `" + table.name + "`\n\n"
text += "### Description: \n\n"
text += table.comment + "\n\n"
text += "### Columns: \n\n"
text += "| Column | Data type | Attributes | Default | Description |\n| --- | --- | --- | --- | --- |\n"
for column in table.columns:
text += writeColumnDoc(column, table)
text += "\n\n"
if (len(table.indices)):
text += "### Indices: \n\n"
text += "| Name | Columns | Type | Description |\n| --- | --- | --- | --- |\n"
for index in table.indices:
text += writeIndexDoc(index)
text += "\n\n"
return text
def writeColumnDoc(column, table):
# column name
text = "| `" + column.name + "`"
# column type name
if column.simpleType:
text += " | " + column.simpleType.name
# column max lenght if any
if column.length != -1:
text += "(" + str(column.length) + ")"
else:
text += " | "
text += " | "
# column attributes
attribs = [];
isPrimary = False;
isUnique = False;
for index in table.indices:
if index.indexType == "PRIMARY":
for c in index.columns:
if c.referencedColumn.name == column.name:
isPrimary = True
break
if index.indexType == "UNIQUE":
for c in index.columns:
if c.referencedColumn.name == column.name:
isUnique = True
break
# primary?
if isPrimary:
attribs.append("PRIMARY")
# auto increment?
if column.autoIncrement == 1:
attribs.append("Auto increments")
# not null?
if column.isNotNull == 1:
attribs.append("Not null")
# unique?
if isUnique:
attribs.append("Unique")
text += ", ".join(attribs)
# column default value
text += " | " + (("`" + column.defaultValue + "`") if column.defaultValue else " ")
# column description
text += " | " + (nl2br(column.comment) if column.comment else " ")
# foreign key
for fk in table.foreignKeys:
if fk.columns[0].name == column.name:
text += ("<br /><br />" if column.comment else "") + "**foreign key** to column `" + fk.referencedColumns[0].name + "` on table `" + fk.referencedColumns[0].owner.name + "`."
break
# finish
text += " |" + "\n"
return text
def writeIndexDoc(index):
# index name
text = "| " + index.name
# index columns
text += " | " + ", ".join(map(lambda x: "`" + x.referencedColumn.name + "`", index.columns))
# index type
text += " | " + index.indexType
# index description
text += " | " + (nl2br(index.comment) if index.comment else " ")
# finish
text += " |\n"
return text
def nl2br(text):
return "<br />".join(map(lambda x: x.strip(), text.split("\n")))
# Schema documentation
Generated by [MySQL Workbench Model Documentation plugin](https://github.com/letrunghieu/mysql-workbench-plugin-doc-generating) - Copyright (c) 2015 Hieu Le
## Table: `DBinfo`
### Description:
### Columns:
| Column | Data type | Attributes | Default | Description |
| --- | --- | --- | --- | --- |
| `Date` | VARCHAR(25) | Not null | | |
| `Excel_file_used` | VARCHAR(150) | Not null | | |
| `Matlab_file_used` | VARCHAR(150) | Not null | | |
| `created_by_user` | VARCHAR(100) | Not null | | |
| `Schema_version` | DOUBLE | Not null | | |
| `notes` | TEXT | | `NULL` | |
## Table: `busconfiguration`
### Description:
### Columns:
| Column | Data type | Attributes | Default | Description |
| --- | --- | --- | --- | --- |
| `idNetworkConfig` | INT | PRIMARY, Not null | | **foreign key** to column `idNetworkConfig` on table `networkconfiginfo`. |
| `idBus` | INT | PRIMARY, Not null | | **foreign key** to column `idBus` on table `busdata`. |
| `BusName` | VARCHAR(45) | | `NULL` | |
| `Vmax` | DOUBLE | | `'1.1'` | |
| `Vmin` | DOUBLE | | `'0.9'` | |
| `WindShare` | DOUBLE | | `NULL` | |
| `SolarShare` | DOUBLE | | `NULL` | |
| `idDistProfile` | INT | | `NULL` | |
### Indices:
| Name | Columns | Type | Description |
| --- | --- | --- | --- |
| PRIMARY | `idNetworkConfig`, `idBus` | PRIMARY | |
| fk_BusDataConfiguration_BusData1_idx | `idBus` | INDEX | |
| fk_BusDataConfiguration_NetworkConfigInfo1_idx | `idNetworkConfig` | INDEX | |
## Table: `busdata`
### Description:
### Columns:
| Column | Data type | Attributes | Default | Description |
| --- | --- | --- | --- | --- |
| `idBus` | INT | PRIMARY, Not null | | |
| `internalBusId` | INT | | `NULL` | |
| `BusName` | VARCHAR(45) | | `NULL` | |
| `SwissgridNodeCode` | VARCHAR(45) | | `NULL` | |
| `ZoneId` | INT | | `NULL` | |
| `X_Coord` | FLOAT | | `NULL` | X coordinate in LV03 format |
| `Y_Coord` | FLOAT | | `NULL` | Y coordinate in LV03 format |
| `BusType` | VARCHAR(2) | | `'PQ'` | |
| `Qd` | DOUBLE | | `'0'` | |
| `Pd` | DOUBLE | | `'0'` | |
| `Gs` | DOUBLE | | `'0'` | |
| `Bs` | DOUBLE | | `'0'` | |
| `baseKV` | DOUBLE | | `NULL` | |
| `Country` | VARCHAR(45) | | `NULL` | |
| `SubRegion` | VARCHAR(45) | | `NULL` | |
| `StartYr` | DOUBLE | | `NULL` | |
| `EndYr` | DOUBLE | | `NULL` | |
| `WindShare` | DOUBLE | | `NULL` | |
| `SolarShare` | DOUBLE | | `NULL` | |
### Indices:
| Name | Columns | Type | Description |
| --- | --- | --- | --- |
| PRIMARY | `idBus` | PRIMARY | |
## Table: `distprofiles`
### Description:
### Columns:
| Column | Data type | Attributes | Default | Description |
| --- | --- | --- | --- | --- |
| `idDistProfile` | INT | PRIMARY, Auto increments, Not null | | |
| `name` | VARCHAR(45) | | `NULL` | |
| `type` | VARCHAR(45) | | `NULL` | |
| `resolution` | VARCHAR(45) | | `NULL` | |
| `unit` | VARCHAR(45) | | `NULL` | |
| `timeSeries` | JSON | | `NULL` | |
### Indices:
| Name | Columns | Type | Description |
| --- | --- | --- | --- |
| PRIMARY | `idDistProfile` | PRIMARY | |
## Table: `genconfiginfo`
### Description:
### Columns:
| Column | Data type | Attributes | Default | Description |
| --- | --- | --- | --- | --- |
| `idGenConfig` | INT | PRIMARY, Not null | | |
| `name` | VARCHAR(45) | | `NULL` | |
| `year` | INT | | `NULL` | |
### Indices:
| Name | Columns | Type | Description |
| --- | --- | --- | --- |
| PRIMARY | `idGenConfig` | PRIMARY | |
## Table: `genconfiguration`
### Description:
### Columns:
| Column | Data type | Attributes | Default | Description |
| --- | --- | --- | --- | --- |
| `idGenConfig` | INT | PRIMARY, Not null | | **foreign key** to column `idGenConfig` on table `genconfiginfo`. |
| `idBus` | INT | PRIMARY, Not null | | **foreign key** to column `idBus` on table `busdata`. |
| `idGen` | INT | PRIMARY, Not null | | **foreign key** to column `idGen` on table `gendata`. |
| `GenName` | VARCHAR(55) | | `NULL` | |
| `idProfile` | INT | | `NULL` | **foreign key** to column `idProfile` on table `profiledata`. |
| `CandidateUnit` | TINYINT | | `NULL` | |
| `Pmax` | DOUBLE | | `NULL` | |
| `Pmin` | DOUBLE | | `NULL` | |
| `Qmax` | DOUBLE | | `NULL` | |
| `Qmin` | DOUBLE | | `NULL` | |
| `Emax` | DOUBLE | | `NULL` | |
| `Emin` | DOUBLE | | `NULL` | |
| `E_ini` | DOUBLE | | `NULL` | |
| `VOM_Cost` | DOUBLE | | `NULL` | nonFuel variable O&M cost in Euro/MWh |
| `FOM_Cost` | DOUBLE | | `NULL` | Fixed O&M cost in Euro/MW/year |
| `InvCost` | DOUBLE | | `NULL` | annualised investment cost for generator in Euro/MW |
| `InvCost_E` | DOUBLE | | `NULL` | annualized investment cost for storage capacity in Euro/MW |
| `StartCost` | DOUBLE | | `NULL` | |
| `TotVarCost` | DOUBLE | | `NULL` | |
| `FuelType` | VARCHAR(45) | | `NULL` | |
| `status` | DOUBLE | | `NULL` | |
| `HedgeRatio` | DOUBLE | | `NULL` | |
### Indices:
| Name | Columns | Type | Description |
| --- | --- | --- | --- |
| PRIMARY | `idGenConfig`, `idBus`, `idGen` | PRIMARY | |
| fk_GenComposition_BusData1_idx | `idBus` | INDEX | |
| fk_GenComposition_GenData1_idx | `idGen` | INDEX | |
| fk_GenConfiguration_ProfileData1_idx | `idProfile` | INDEX | |
| fk_GenConfiguration_GenConfigInfo1_idx | `idGenConfig` | INDEX | |
## Table: `gendata`
### Description:
### Columns:
| Column | Data type | Attributes | Default | Description |
| --- | --- | --- | --- | --- |
| `idGen` | INT | PRIMARY, Not null | | |
| `GenName` | VARCHAR(55) | | `NULL` | Unit name |
| `GenType` | VARCHAR(45) | | `NULL` | Basic gen type (Hydro, Cons, RES) |
| `Technology` | VARCHAR(45) | | `NULL` | Technology subtype (Dam, Pump, RoR, Nucl, Lignite, Coal, GasCC, GasSC, Biomass, Oil, Wind, PV, GeoTh, etc) |
| `UnitType` | VARCHAR(45) | | `NULL` | Dispatchable or NonDispatchable (used to know which gens are controllable and can be used for reserves) |
| `StartYr` | DOUBLE | | `NULL` | Year this generator was first online (default = 2012) |
| `EndYr` | DOUBLE | | `NULL` | Last year this generator is online |
| `GenEffic` | DOUBLE | | `NULL` | Fractional generator efficiency (MWh elec / MW heat) |
| `CO2Rate` | DOUBLE | | `NULL` | CO2 emission rate (ton / MWh elec) |
| `eta_dis` | DOUBLE | | `NULL` | |
| `eta_ch` | DOUBLE | | `NULL` | |
| `RU` | DOUBLE | | `NULL` | Ramp Up rate (MW/min) |
| `RD` | DOUBLE | | `NULL` | Ramp Down Rate (MW/min) |
| `RU_start` | DOUBLE | | `NULL` | Ramp Up Rate during Start Up (MW/min) |
| `RD_shutd` | DOUBLE | | `NULL` | Ramp Down Rate during Shut Down (MW/min) |
| `UT` | INT | | `NULL` | Minimum Up Time (hr) |
| `DT` | INT | | `NULL` | Minimum Down Time (hr) |
| `Pini` | DOUBLE | | `NULL` | Initial power generation level at first time interval of simulation (MW) |
| `Tini` | DOUBLE | | `NULL` | Number of hours generator has already been online at first time interval of simulation (MW) |
| `meanErrorForecast24h` | DOUBLE | | `NULL` | normalised mean error for renewable generation forecasted 24 hrs ahead (dimensionless) |
| `sigmaErrorForecast24h` | DOUBLE | | `NULL` | standard deviation for renewable generation forecasted 24 hrs ahead (dimensionless) |
### Indices:
| Name | Columns | Type | Description |
| --- | --- | --- | --- |
| PRIMARY | `idGen` | PRIMARY | |
## Table: `lineconfiguration`
### Description:
### Columns:
| Column | Data type | Attributes | Default | Description |
| --- | --- | --- | --- | --- |
| `idNetworkConfig` | INT | PRIMARY, Not null | | **foreign key** to column `idNetworkConfig` on table `networkconfiginfo`. |
| `idLine` | INT | PRIMARY, Not null | | **foreign key** to column `idLine` on table `linedata`. |
| `LineName` | VARCHAR(45) | Not null | | |
| `idFromBus` | INT | PRIMARY, Not null | | **foreign key** to column `idBus` on table `busdata`. |
| `idToBus` | INT | PRIMARY, Not null | | **foreign key** to column `idBus` on table `busdata`. |
| `angmin` | DOUBLE | | `'-360'` | |
| `angmax` | DOUBLE | | `'360'` | |
| `status` | DOUBLE | | `NULL` | |
| `FromBusName` | VARCHAR(45) | | `NULL` | |
| `ToBusName` | VARCHAR(45) | | `NULL` | |
| `FromCountry` | VARCHAR(45) | | `NULL` | |
| `ToCountry` | VARCHAR(45) | | `NULL` | |
| `Ind_CrossBord` | INT | | `NULL` | |
| `Ind_Agg` | INT | | `NULL` | |
| `Ind_HVDC` | INT | | `NULL` | |
| `Candidate` | TINYINT | | `NULL` | |
| `CandCost` | DOUBLE | | `NULL` | |
### Indices:
| Name | Columns | Type | Description |
| --- | --- | --- | --- |
| PRIMARY | `idNetworkConfig`, `idLine`, `idFromBus`, `idToBus` | PRIMARY | |
| fk_LineConfiguration_BusData1_idx | `idFromBus` | INDEX | |
| fk_LineConfiguration_BusData2_idx | `idToBus` | INDEX | |
| fk_LineConfiguration_LineData1_idx | `idLine` | INDEX | |
| fk_LineConfiguration_NetworkconfigInfo1_idx | `idNetworkConfig` | INDEX | |
## Table: `linedata`
### Description:
### Columns:
| Column | Data type | Attributes | Default | Description |
| --- | --- | --- | --- | --- |
| `idLine` | INT | PRIMARY, Not null | | |
| `LineName` | VARCHAR(45) | Not null | | |
| `r` | DOUBLE | | `NULL` | |
| `x` | DOUBLE | | `NULL` | |
| `b` | DOUBLE | | `NULL` | |
| `rateA` | DOUBLE | | `NULL` | |
| `rateB` | DOUBLE | | `NULL` | |
| `rateC` | DOUBLE | | `NULL` | |
| `StartYr` | DOUBLE | | `NULL` | |
| `EndYr` | DOUBLE | | `NULL` | |
| `kV` | DOUBLE | | `NULL` | |
| `MVA_Winter` | DOUBLE | | `NULL` | |
| `MVA_Summer` | DOUBLE | | `NULL` | |
| `MVA_SprFall` | DOUBLE | | `NULL` | |
| `length` | DOUBLE | | `NULL` | |
### Indices:
| Name | Columns | Type | Description |
| --- | --- | --- | --- |
| PRIMARY | `idLine` | PRIMARY | |
## Table: `loadconfiginfo`
### Description:
### Columns:
| Column | Data type | Attributes | Default | Description |
| --- | --- | --- | --- | --- |
| `idLoadConfig` | INT | PRIMARY, Not null | | |
| `name` | VARCHAR(45) | | `NULL` | |
| `year` | INT | | `NULL` | |
### Indices:
| Name | Columns | Type | Description |
| --- | --- | --- | --- |
| PRIMARY | `idLoadConfig` | PRIMARY | |
## Table: `loadconfiguration`
### Description:
### Columns:
| Column | Data type | Attributes | Default | Description |
| --- | --- | --- | --- | --- |
| `idLoadConfig` | INT | PRIMARY, Not null | | **foreign key** to column `idLoadConfig` on table `loadconfiginfo`. |
| `idBus` | INT | PRIMARY, Not null | | **foreign key** to column `idBus` on table `busdata`. |
| `idLoad` | INT | PRIMARY, Not null | | **foreign key** to column `idLoad` on table `loaddata`. |
| `idProfile` | INT | | `NULL` | **foreign key** to column `idProfile` on table `profiledata`. |
| `loadFactor` | DOUBLE | | `NULL` | |
### Indices:
| Name | Columns | Type | Description |
| --- | --- | --- | --- |
| PRIMARY | `idLoadConfig`, `idBus`, `idLoad` | PRIMARY | |
| fk_LoadConfiguration_LoadData1_idx | `idLoad` | INDEX | |
| fk_LoadConfiguration_BusData1_idx | `idBus` | INDEX | |
| fk_LoadConfiguration_ProfileData1_idx | `idProfile` | INDEX | |
| fk_LoadConfiguration_LoadConfigInfo1_idx | `idLoadConfig` | INDEX | |
## Table: `loaddata`
### Description:
### Columns:
| Column | Data type | Attributes | Default | Description |
| --- | --- | --- | --- | --- |
| `idLoad` | INT | PRIMARY, Not null | | |
| `LoadType` | VARCHAR(45) | | `NULL` | |
| `Pd` | DOUBLE | | `NULL` | |
| `Qd` | DOUBLE | | `NULL` | |
| `hedgeRatio` | DOUBLE | | `NULL` | |
| `meanForecastError24h` | DOUBLE | | `NULL` | |
| `sigmaForecastError24h` | DOUBLE | | `NULL` | |
### Indices:
| Name | Columns | Type | Description |
| --- | --- | --- | --- |
| PRIMARY | `idLoad` | PRIMARY | |
## Table: `marketsconfiguration`
### Description:
### Columns:
| Column | Data type | Attributes | Default | Description |
| --- | --- | --- | --- | --- |
| `idMarketsConfig` | INT | PRIMARY, Not null | | |