Thanks for the fantastic tool.
I would appreciate something more human readable like PlantUML.
I wrote this little script that might help with the idea. It's a hacky script and not in JS so yeah... IDK if it is any good or useful for the dev team (in case considering the idea), but I leave it here just in case somebody wants to use it.
#!/bin/sh
# Convert a SQL database to Plantuml
# $1: Database file
# $2: (Optional) Output name (exluding the extension)
# TODO convert sql to plantuml
out="${2:-$1}.plantuml"
sqleton "$1" -o "$1.plain" || exit 1
[ -f "$out" ] && echo "File '$out' already exists" && exit 1
head "$1.plain" -n-1 | tail -n+2 | awk '
BEGIN {
INDENT = " ";
print "@startuml ERD\n";
}
{
if ($1 == "node") {
print "entity " $2 " {";
split($0, row, "|");
rows = split(row[2], data, ">");
# data[1] => table tag
# loop:
# data[2..3] => tr and td tags
# data[4] => field name + font tag
# data[5] => bold tag
# data[6] => type + bold closing
# data[7] => font closing
# data[8..9] => tr and td tags closing
if (rows >= 4 + 7) process(data[4], data[6]);
for (i=12; i <= rows - 7; i = i + 8) process(data[i], data[i + 2]);
print "}\n";
} else if ($1 == "edge") {
print $2 " --> " $3;
}
}
END {
print "\n@enduml";
}
function remove_tags(s){
sub(/ ?<.*/, "", s);
sub(/^ ?/, "", s);
return s;
}
function process(field, type) {
field = remove_tags(field);
type = remove_tags(type);
printf INDENT;
# Move the star of pks to the back
match(field, "*");
if (RLENGTH != -1) field = "* " substr(field, 0, length(field) - RLENGTH);
printf field " : " type;
if (RLENGTH != -1) printf "\n" INDENT "--";
print "";
}
' >"$out"
rm "$1.plain"
This does the conversion below which can be rendered to something like that picture:
Thanks for the fantastic tool. I would appreciate something more human readable like PlantUML.
I wrote this little script that might help with the idea. It's a hacky script and not in JS so yeah... IDK if it is any good or useful for the dev team (in case considering the idea), but I leave it here just in case somebody wants to use it.
This does the conversion below which can be rendered to something like that picture: