Database diagram support
Closed this issue · 2 comments
- Extend the handling of fenced block languages to include "database"
- Parse the content of the fenced block as YAML
- Use the parsed values to extract schema information from a live database and generate source for a Mermaid entity relationship diagram.
- Render the generated Mermaid diagram as SVG
- Based on the method used for Kroki diagrams add caching
For step 2, parse YAML like so. token.text
gives you everything between the fences.
case "PUSH":
resolvedConfig = yaml.parse(token.text);
stack.push(resolvedConfig);
break;
The YAML parser is already in scope unless you break out the logic into a new file in which case you can import like so:
import * as yaml from "yaml";
Sample
```database
DatabaseType: postgresql
ConnectionString: Host=localhost;Port=5432;Database=mydatabase;Username=user;Password=secret
Schema: public
Tables:
- Offers
- Orders
- Passes
Detail: column names
```
DatabaseType
- postgresql
- mssql
ConnectionString
A dotnet database connection string. Depending on your setup you may need to embed the password. In that case create a user with permissions limited to reading the schema details.
Schema
The schema containing the tables to be diagrammed. When this item is omitted, the Postgres default is public
and the MSSQL default is dbo
.
Tables
A list of the tables you want in the diagram. When this item is omitted, the default is all the tables.
Detail
Supported values in decreasing level of detail are
- column types
- column names
- key column names
- table name
When this item is omitted, the default is column names.
That looks like a great first issue. (as discussed offline) I will pick it up and let's see how it goes!
I created a fork to work on this; here it is https://github.com/abdiukov/vsc-print-340.
Do you have any preferences for which db driver/library is better to use?