浏览代码

Anpassungen Testlauf Gerds CARLO

Gerds 10 月之前
父节点
当前提交
390f0b81e4
共有 3 个文件被更改,包括 8 次插入6 次删除
  1. 4 4
      database/db_create.py
  2. 1 1
      database/db_run.py
  3. 3 1
      database/model.py

+ 4 - 4
database/db_create.py

@@ -128,12 +128,12 @@ def create(config_file: str = "database/CARLO.json"):
                 table_client = f'{current_table["dest"]}_{client_db}'
                 select_query = select_queries[table_client]
                 if "WHERE" in select_query:
-                    select_query = select_query.replace("WHERE", "WHERE T1.[timestamp] > '%TS%' AND")
+                    select_query = select_query.replace("WHERE", "WHERE T1.[timestamp] > %TS% AND")
                 elif "ORDER" in select_query:
-                    select_query = select_query.replace("ORDER", "WHERE T1.[timestamp] > '%TS%' ORDER")
+                    select_query = select_query.replace("ORDER", "WHERE T1.[timestamp] > %TS% ORDER")
                 else:
                     print("Dont know where to put WHERE")
-                f.write(f'  call sql_timestamp.bat "{full_table_name}" "{client_db}"\n')
+                f.write(f'  call sql_timestamp.bat "{table_client}" "{full_table_name}" "{client_db}"\n')
                 f.write(f'  call bcp_queryout.bat "{table_client}" "{select_query}"\n')
                 f.write(f'  call bcp_in.bat "{table_client}" "[temp].[{current_table["dest"]}]" "{cfg.temp_db}"\n\n')
 
@@ -161,7 +161,7 @@ def create(config_file: str = "database/CARLO.json"):
         for index, current_table in config.iterrows():
             f.write(f"echo =={current_table['dest']}==\n")
             f.write(f"echo {current_table['dest']} >CON\n")
-            f.write(f"call {current_table['dest']}.bat\n\n")
+            f.write(f"call {cfg.batch_dir}\\{current_table['dest']}.bat 1\n\n")
 
 
 if __name__ == "__main__":

+ 1 - 1
database/db_run.py

@@ -4,7 +4,7 @@ import subprocess
 
 
 def task(name: str) -> subprocess.Popen:
-    return subprocess.Popen(f'C:\\Windows\\System32\\cmd.exe /C "{name}"', stdout=subprocess.DEVNULL).wait()
+    return subprocess.Popen(f'C:\\Windows\\System32\\cmd.exe /C "{name} 1"', stdout=subprocess.DEVNULL).wait()
 
 
 def run(base_dir: str, max: int = 5) -> None:

+ 3 - 1
database/model.py

@@ -132,6 +132,7 @@ class DatabaseInspect:
     def get_pkey(self, table, catalog):
         source_insp_cols = [col.column_name for col in self.cursor.primaryKeys(table=table, catalog=catalog)]
         if len(source_insp_cols) == 0:
+            self.cursor.execute(f"USE {catalog}")
             q = self.cursor.execute(
                 "SELECT COLUMN_NAME "
                 "FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE "
@@ -139,6 +140,7 @@ class DatabaseInspect:
                 f"AND TABLE_NAME = '{self.convert_table(table)}' "  # AND TABLE_SCHEMA = 'dbo'"
             )
             source_insp_cols = [col[0] for col in q.fetchall()]
+            self.cursor.execute(f"USE {self.dsn.database}")
         return source_insp_cols
 
     def convert_table(self, table):
@@ -176,5 +178,5 @@ def create_db_ini(cfg: DbCreateConfig):
         fwh.write("\n\n")
         fwh.write(cfg.source_dsn.conn_ini("SOURCE"))
         fwh.write("\n\n")
-        fwh.write(cfg.source_dsn.conn_ini("DEST"))
+        fwh.write(cfg.dest_dsn.conn_ini("DEST"))
         fwh.write("\n")