I’m encountering an issue with a Python script that updates rows in a MySQL database table. The script is intended to set the contact_id column to NULL for all rows where contact_id is currently set to 1 in the aos_products table. However, when I run the script, it doesn’t seem to update the rows as expected. Instead, it encounters an error message “Error: Unread result found”.
Here’s the relevant portion of the Python script:
if result == 0:
query = "UPDATE aos_products SET contact_id=NULL WHERE contact_id=1"
cursor.execute(query)
# Log date and actions performed
with open("ADILog.txt", "a") as f:
f.write(f"{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')} Actions Performed: {action_count} Actions Left: {result - action_count} Finished Uploadingn")
print("All Results Updated and Reset to process on next run")
exit()
I cant get it to work and it seems to fail with ‘cursor.execute(query)’ part, any idea on my solution would be greatly appreciated.
kuwam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.