From 116d1cda5fc219996f7eb99427977a52d3c3a6f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Fri, 6 Nov 2015 15:34:14 +0000 Subject: [PATCH] new script to convert sql schema files into graphviz dot --- scripts/sql-to-dot.sed | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 scripts/sql-to-dot.sed diff --git a/scripts/sql-to-dot.sed b/scripts/sql-to-dot.sed new file mode 100755 index 0000000..a648f81 --- /dev/null +++ b/scripts/sql-to-dot.sed @@ -0,0 +1,25 @@ +#! /bin/sed -f +1idigraph schema { + +# remove newlines +:a;N;$!ba;s/\n/ /g + +s| *CREATE TABLE[^("'`]*[`"']\?\([a-z]\+\)[`"']\? *|\n \1\n [shape=none, margin=0, label=<\n \n \n|ig + +s/varchar *( *\([0-9]\+\) *)/varchar[\1]/ig + +s/ *PRIMARY KEY *( *[`"']\?\([a-z]\+\)[`"']\? *) *[,)]//ig + +:b;s/\([a-z]\+\)\([^;]*\)FOREIGN KEY *( *[`"']\?\([a-z]\+\)[`"']\? *) *REFERENCES *[`"']\?\([a-z]\+\)[`"'] *( *[`"']\?\([a-z]\+\)[`"']\? *) *\([^,)]*\)[,)]\(.*\)/\1\2\7\n \1:\3 -> \4:\5/ig;tb + +s| *COMMENT *= *[`"']\?\([^`"']*\)[`"']\?| |ig + +s| *[`"']\([a-z]\+\)[`"'] *\([^,)]*\) *COMMENT *[`"']\([^`"']*\)[`"'] *[,)]| \n|ig + +s/ *ENGINE *= *\w* *//ig +s/ *DEFAULT *CHARSET *= *\w* *//ig +s/ *CHARACTER *SET *=\? *\w* *//ig +s|;|\n
\1
\1
\1\2\3
\n >];\n|ig +s/(//ig + +$a}