Browse Source

add function to draw er diagram

ogert 2 years ago
parent
commit
bff4083676
1 changed files with 15 additions and 1 deletions
  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)