# ...
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:
print(f"Executing source query: {source_query}") # Add this line
source_df = pd_read_sql(source_query, con=engine_source)
if not source_df.empty:
# ...
try:
source_df.to_sql(name=target_table, con=engine_target, if_exists='append', index=False)
num_records = len(source_df)
query_info = f"-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ STATUS|{replicationTarget}| TABLE| {eprm_table_name}\n"
query_info += f"-- #Query: Inserted {num_records} records into {target_table}\n"
write_sql(query_info)
print(f"Inserted {num_records} records into {target_table}")
logging.info(f"Inserted {num_records} records into {target_table}")
except Exception as e:
print(f"Error occurred while inserting data into {target_table}: {e}")
logging.error(f"Error occurred while inserting data into {target_table}: {e}")
else:
print(f"No records fetched from source query: {source_query}") # Add this line
except mysql.connector.Error as err:
print(f"Error occurred while executing the source query: {source_query}: {err}")
logging.error(f"Error occurred while executing the source query: {source_query}: {err}")
continue
except Exception as e:
print(f"An error occurred during source data processing: {e}")
logging.error(f"An error occurred during source data processing: {e}")
continue
# ...