gc-server3 пре 3 месеци
родитељ
комит
0d45a124f5
1 измењених фајлова са 7 додато и 4 уклоњено
  1. 7 4
      database/db_compare.py

+ 7 - 4
database/db_compare.py

@@ -20,6 +20,7 @@ def convert_column(col):
     if col is None:
         return "null"
     if isinstance(col, str):
+        col = col.replace("'", "")
         return f"'{col}'"
     if isinstance(col, bytes):
         return decode_ts(col)
@@ -157,6 +158,12 @@ def compare_details(source_table: SourceTable2, dest_table: DestTable, query_cou
 
 
 def resolve_mismatch(source_table: SourceTable2, dest_table: DestTable, cfg: DbCreateConfig, ts_lists: list[str]):
+    if len(ts_lists[0]) > 100_000 or len(ts_lists[1]) > 100_000:
+        print(f"!! Tabellen-Import fuer {source_table.table_client} abgebrochen: zu viele Zeilen !!")
+        print("  Veraltete Datensaetze in Ziel: " + str(ts_lists[0].count(",") + 1))
+        print("  Fehlende Datensaetze in Ziel: " + str(ts_lists[1].count(",") + 1))
+        return
+
     if ts_lists[0] != "":
         delete_query = (
             f"DELETE FROM {dest_table.full_table_name} "
@@ -166,10 +173,6 @@ def resolve_mismatch(source_table: SourceTable2, dest_table: DestTable, cfg: DbC
         print(res.rowcount)
         res.commit()
 
-    if len(ts_lists[1]) > 100_000:
-        print(f"Tabellen-Import fuer {source_table.table_client} abgebrochen: zu viele Zeilen!")
-        return
-
     res = cfg.dest_inspect.cursor.execute(f"TRUNCATE TABLE {dest_table.temp_table_name}")
     res.commit()
     print(res.rowcount)