Add in soft failure for sql delete

This commit is contained in:
Brian Read 2024-06-28 10:41:04 +01:00
parent 6cb877d358
commit c5a708a382

View File

@ -757,17 +757,20 @@ if __name__ == "__main__":
""") """)
# and prune the DB here if needed. # and prune the DB here if needed.
# Delete existing records for the given date # Delete existing records for the given date
delete_query = """ try:
DELETE FROM SummaryLogs delete_query = """
WHERE Date = %s DELETE FROM SummaryLogs
""" WHERE Date = %s
cursor.execute(delete_query, (analysis_date)) """
# Get the number of records deleted cursor.execute(delete_query, (analysis_date))
rows_deleted = cursor.rowcount # Get the number of records deleted
print(rows_deleted) rows_deleted = cursor.rowcount
#quit() print(rows_deleted)
if rows_deleted > 0: #quit()
print(f"Deleted {rows_deleted} rows for {analysis_date} ") if rows_deleted > 0:
print(f"Deleted {rows_deleted} rows for {analysis_date} ")
except mysql.connector.Error as e:
print(f"SQL Delete failed ({delete_query}) ({e}) ")
except mysql.connector.Error as e: except mysql.connector.Error as e:
print(f"Unable to connect to {DBName} on {DBHost} port {DBPort} error ({e}) ") print(f"Unable to connect to {DBName} on {DBHost} port {DBPort} error ({e}) ")
saveData = False saveData = False