0

I would like produce a file which contains pairs of tables; a master on the left and a detail on the right or said another way parent and child.

In the article: "How to Visualize Your SQLite Database with One Command" using --output-file=output.png probably has some intermediate files that are used by GraphViz to provide the data. And for me a simple .dot file would be just fine. digraph Net {"Population" -> "deaths" "Population" -> "births" } What is the code necessary to do this?

1 Answers1

0

It is quite easy to do this kind of customization with SchemaCrawler and a little bit of Python scripting. Take a look at How to Generate Mermaid Diagrams for Your Database. If you tweak the Python script in that article, it will generate the graph that you would like to have.

from schemacrawler.schema import TableRelationshipType # pylint: disable=import-error

print('digraph Net {')
for table in catalog.tables:
  for childTable in table.getRelatedTables(TableRelationshipType.child):
    print('  "' + table.fullName + '" -> "' + childTable.fullName + '"')
print('}')

Sualeh Fatehi, SchemaCrawler

Sualeh Fatehi
  • 4,700
  • 2
  • 24
  • 28