Prechádzať zdrojové kódy

SQL-Umwandlung (funktioniert noch nicht)

gc-server3 10 mesiacov pred
rodič
commit
706acb3675
1 zmenil súbory, kde vykonal 18 pridanie a 0 odobranie
  1. 18 0
      sandbox/sql_refactoring.py

+ 18 - 0
sandbox/sql_refactoring.py

@@ -0,0 +1,18 @@
+from pathlib import Path
+
+import sqlglot
+from sqlglot.optimizer import optimize
+
+
+def main():
+    output_path = Path("sandbox/sql/converted")
+    for file in Path("sandbox/sql/raw").glob("*.sql"):
+        with file.open("r", encoding="latin-1") as frh:
+            res = optimize(sqlglot.parse_one(frh.read(), read="tsql"))
+            output_file = output_path / file.name
+            with output_file.open("w", encoding="latin-1") as fwh:
+                fwh.write(res.sql(dialect="tsql", pretty=True))
+
+
+if __name__ == "__main__":
+    main()