# ... (previous code)
for _, row in df.iterrows():
eprm_table_name = row['eprm_table_name']
if eprm_table_name != 'PKG_PRD_FED_EXT_ATTRS':
source_query = f"SELECT * FROM {schema_source}.{eprm_table_name} WHERE release_id='{releaseId}' AND op_id='{opId}' AND bu_id='{buId}'"
try:
source_df = pd_read_sql(source_query, con=conn_source)
if not source_df.empty:
columns = ', '.join(source_df.columns)
values = ', '.join([f"({', '.join([f'"{value}"' for value in row])})" for _, row in source_df.iterrows()])
query_insert = f"INSERT INTO {schema_target}.{eprm_table_name} ({columns}) VALUES {values}"
try:
cursor_target.execute(query_insert)
conn_target.commit()
query_info = f"-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ STATUS|{replicationTarget}| TABLE| {eprm_table_name}\n"
query_info += f"-- #Query: Inserted {source_df.shape[0]} records\n"
query_info += query_insert + ";\n"
write_sql(query_info)
print(f"Inserted {source_df.shape[0]} records into {eprm_table_name}")
logging.info(f"Inserted {source_df.shape[0]} records into {eprm_table_name}")
except mysql.connector.Error as err:
print(f"Error occurred while inserting records into {eprm_table_name}: {err}")
logging.info(f"Error occurred while inserting records into {eprm_table_name}: {err}")
except mysql.connector.Error as err:
print(f"Error occurred while executing the query: {source_query}: {err}")
logging.info(f"Error occurred while executing the query: {source_query}: {err}")
# ... (remaining code)