【问题标题】:SchemaCrawler Code to produce a simple .dot fileSchemaCrawler 代码生成一个简单的 .dot 文件
【发布时间】:2022-01-05 19:04:24
【问题描述】:

我想生成一个包含成对表的文件;左边是大师,右边是细节,或者说父母和孩子。

在文章:“如何使用一个命令可视化您的 SQLite 数据库”中,使用 --output-file=output.png 可能有一些中间文件,GraphViz 使用这些文件来提供数据。对我来说,一个简单的 .dot 文件就可以了。 digraph Net {"Population" -> "deaths" "Population" -> "births" } 执行此操作所需的代码是什么?

【问题讨论】:

    标签: schemacrawler


    【解决方案1】:

    使用 SchemaCrawler 和一点 Python 脚本可以很容易地进行这种自定义。看看How to Generate Mermaid Diagrams for Your Database。如果您调整该文章中的 Python 脚本,它将生成您想要的图表。

    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

    【讨论】:

      猜你喜欢
      • 2014-08-27
      • 2011-01-26
      • 1970-01-01
      • 2010-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多