瀏覽代碼

add function to draw er diagram

ogert 3 年之前
父節點
當前提交
bff4083676
共有 1 個文件被更改,包括 15 次插入1 次删除
  1. 15 1
      cdplib/db_handlers/MSSQLHandler.py

+ 15 - 1
cdplib/db_handlers/MSSQLHandler.py

@@ -181,4 +181,18 @@ class MSSQLHandler:
                 self._log.error("Could not drop the table, Error {}".format(error))
 
         else:
-            self._log.info("The table can't be dropped because it does not exist")
+            self._log.info("The table can't be dropped because it does not exist")
+
+    def draw_er_diagram_from_db(self, diagram_path: str,
+                                schema: str = None,
+                                include_tables: list = None):
+        
+        diagram_dir = os.path.dirname(diagram_path)
+        if diagram_dir != "":
+            os.makedirs(diagram_dir, exist_ok=True)
+
+        import eralchemy
+        eralchemy.render_er(self._db_uri,
+                            diagram_path,
+                            schema=schema,
+                            include_tables=include_tables)