# Find rows with differences
diff_df = source_df.compare(target_df, keep_shape=True)
if not diff_df.empty:
# Generate an update query dynamically
update_query = f"UPDATE {table_name} SET "
column_updates = []
for column_name in diff_df.columns:
source_col = diff_df[column_name]['self']
target_col = diff_df[column_name]['other']
# Identify rows where values are different
diff_rows = np.where(source_col != target_col)[0]
for row_number in diff_rows:
source_val = source_col.iloc[row_number]
target_val = target_col.iloc[row_number]
# Include the column update in the query
column_updates.append(f"{column_name} = '{source_val}'")
update_query += ", ".join(column_updates)
print(update_query)
# Execute the update query
cursor_ext.execute(update_query)
instead of using rownnum in where condition can you use the values of this
primary_df['eprm_table_col_pk'] =source_row[primary_df['eprm_table_col_pk']]
just predefine thos values and in the update statement where clause use them