try:
# ... (existing code)
for _, row in filtered_df.iterrows():
eprm_table_name = row['eprm_table_name']
if eprm_table_name != 'PKG_PRD_FED_EXT_ATTRS':
source_query = f"SELECT * FROM {schema_ext}.{eprm_table_name} WHERE release_id='{releaseId}' AND op_id='{opId}' AND bu_id='{buId}'"
try:
source_df = pd_read_sql(source_query, con=connection_ext)
if not source_df.empty:
columns = ', '.join(source_df.columns)
values = ', '.join([f"'{value}'" for value in source_df.iloc[0]])
query_del = f"INSERT INTO {schema_ext}.{eprm_table_name} ({columns}) VALUES ({values})"
try:
cursor_ext.execute(query_del)
connection_ext.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_del + ";\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}")
logging.info("COMPLETED")
except Exception as e:
print("Error - {} . Line No - {} ".format(str(e), str(sys.exc_info()[-1].tb_lineno)))
print("An Error occurred while constructing dataframe:", str(e))
# ... (existing finally block)