簡體   English   中英

SchemaCrawler 代碼生成 simple.dot 文件

[英]SchemaCrawler Code to produce a simple .dot file

我想生成一個包含成對表的文件; 左邊是大師,右邊是細節,或者說父母和孩子的另一種方式。

在文章:“如何使用一個命令可視化您的 SQLite 數據庫”中使用 --output-file=output.png 可能有一些中間文件,GraphViz 使用這些文件來提供數據。 對我來說,一個 simple.dot 文件就可以了。 digraph Net {"Population" -> "deaths" "Population" -> "births" } 執行此操作所需的代碼是什么?

使用 SchemaCrawler 和一點點 Python 腳本來進行這種自定義非常容易。 查看如何為您的數據庫生成美人魚圖 如果您調整該文章中的 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM