Untitled
unknown
plain_text
a year ago
2.1 kB
3
Indexable
Never
# ... (previous code) # Fetch data from the etl_ppm_replication_master table primary_query = f"SELECT * FROM {schema_ppm}.etl_ppm_replication_master" df = pd_read_sql(primary_query, con=conn_ppm) # Iterate over each row in the DataFrame and check record counts for _, row in df.iterrows(): eprm_table_name = row['eprm_table_name'] if eprm_table_name != 'PKG_PRD_FED_EXT_ATTRS': query = f"SELECT COUNT(*) FROM {schema_ext}.{eprm_table_name} WHERE release_id='{releaseId}' AND op_id='{opId}' AND bu_id='{buId}'" try: result = pd_read_sql(query, con=connection_ext) count = result.iloc[0, 0] query_info = f"-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ STATUS|{replicationTarget}| TABLE| {eprm_table_name}\n" query_info += f"-- #Query: Result:{count}\n" query_count += 1 query_info += query + ";\n" write_sql(query_info) print(f"Count for {eprm_table_name}: {count} PC_EXT") logging.info(f"Count for {eprm_table_name}: {count}") if query_count > 0: try: result = pd_read_sql(query, con=connection_ext) count = result.iloc[0, 0] query_info = f"-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ STATUS|{replicationTarget}| TABLE| {eprm_table_name}\n" query_info += f"-- #Query: Result:{count}\n" query_count += 1 query_info += query + ";\n" write_sql(query_info) print(f"Count for {eprm_table_name}: {count} PC_EXT for deletion") except Exception as err: print(f"Error occurred while executing the query:{query}: {err}") logging.info(f"Error occurred while executing the query:{query}: {err}") except Exception as err: print(f"Error occurred while executing the query :{query}: {err}") logging.info(f"Error occurred while executing the query:{query}: {err}") # ... (rest of the code)