|
@@ -44,7 +44,8 @@ def create(config_file: str = "database/CARLO.json"):
|
|
|
continue
|
|
|
|
|
|
f.write(f"del {cfg.logs_dir}\\{current_table['dest']}*.* /Q /F >nul 2>nul\n\n")
|
|
|
- f.write('if "%1"=="" (\n')
|
|
|
+ f.write('if "%1"=="" goto :increment\n')
|
|
|
+ f.write("\n:full\n")
|
|
|
f.write(f' call sql_query.bat "TRUNCATE TABLE {full_table_name}"\n')
|
|
|
|
|
|
dest_columns_list = dest_db.get_columns(current_table["dest"])
|
|
@@ -102,9 +103,9 @@ def create(config_file: str = "database/CARLO.json"):
|
|
|
else:
|
|
|
select_columns += f"T1.[{col}], "
|
|
|
elif col == "Client_DB":
|
|
|
- select_columns += f"'{client_db}' as \\\"Client_DB\\\", "
|
|
|
+ select_columns += f"'{client_db}' as [Client_DB], "
|
|
|
else:
|
|
|
- select_columns += "'' as \\\"" + col + '\\", '
|
|
|
+ select_columns += "'' as [" + col + "], "
|
|
|
|
|
|
select_query = select_query.replace("T1.*", select_columns[:-2])
|
|
|
if "timestamp" in source_columns:
|
|
@@ -121,7 +122,8 @@ def create(config_file: str = "database/CARLO.json"):
|
|
|
f'"[{cfg.dest_dsn.schema}].[{current_table["dest"]}]" "{current_table["dest_db"]}"\n'
|
|
|
)
|
|
|
|
|
|
- f.write(") else (\n")
|
|
|
+ f.write(" goto :cleanup\n\n")
|
|
|
+ f.write(":increment\n")
|
|
|
temp_table_name = f"[{cfg.temp_db}].[temp].[{current_table['dest']}]"
|
|
|
f.write(f' call sql_query.bat "TRUNCATE TABLE {temp_table_name}"\n\n')
|
|
|
for client_db, prefix in cfg.clients.items():
|
|
@@ -151,10 +153,10 @@ def create(config_file: str = "database/CARLO.json"):
|
|
|
|
|
|
f.write(f' call sql_query.bat "{insert_query}"\n')
|
|
|
|
|
|
- f.write(")\n\n")
|
|
|
+ f.write("\n:cleanup\n")
|
|
|
for client_db, prefix in cfg.clients.items():
|
|
|
stage_csv = f"{cfg.stage_dir}\\{current_table['dest']}_{client_db}.csv"
|
|
|
- f.write(f'del "{stage_csv}" /F >nul 2>nul\n')
|
|
|
+ f.write(f' del "{stage_csv}" /F >nul 2>nul\n')
|
|
|
|
|
|
with open(f"{cfg.batch_dir}/_{cfg.name}.bat", "w", encoding="cp850") as f:
|
|
|
f.write("@echo off & cd /d %~dp0\n")
|