From 31a43fc346f82e24f0740a162c3372454297fa54 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 24 Dec 2021 15:08:55 +0530 Subject: Wrap SQL visualization code into a function. * visualize-schema.scm (write-sql-visualization, main): New functions. Invoke main. --- visualize-schema.scm | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/visualize-schema.scm b/visualize-schema.scm index 6fb7479..be1b9e4 100644 --- a/visualize-schema.scm +++ b/visualize-schema.scm @@ -166,13 +166,23 @@ relations in TABLES." (table-columns table))) tables)) -(let ((all-tables (tables))) - ((@@ (ccwl graphviz) graph->dot) - ((@@ (ccwl graphviz) graph) 'schema - #:nodes (map (lambda (table) - ((@@ (ccwl graphviz) graph-node) - (table-name table) - `((shape . "none") - (label . ,(table-label table))))) - all-tables) - #:edges (foreign-key-graphviz-edges all-tables)))) +(define (write-sql-visualization port) + "Write a visualization of the SQL schema in graphviz dot syntax to +PORT." + (let ((all-tables (tables))) + (graph->dot + (graph 'schema + #:nodes (map (lambda (table) + (graph-node + (table-name table) + `((shape . "none") + (label . ,(table-label table))))) + all-tables) + #:edges (foreign-key-graphviz-edges all-tables)) + port))) + +(define (main) + (call-with-output-file "sql.dot" + write-sql-visualization)) + +(main) -- cgit v1.2.3