0

I'm currently trying to make changes to a table using the MySQLdb module with Python, but for some reason the change is not actually occurring. I'm definitely connecting fine, because I can fetch a result so for some reason the update is not working. Code is as follows

import MySQLdb

db = MySQLdb.connect(host="localhost", user="root", passwd="", db="rpi")
cur = db.cursor()
cur.execute("UPDATE heating SET mode = 'change'")

cur.close()
db.close()

There is only one row in the table heating. I am not yet running this from a Raspberry Pi.

Why is the database not being updated? I'm not too sure how to get an error with the MySQLdb module, so help with that would be appreciated too, if not required to fix this issue.

1 Answer 1

2

You need to commit your SQL statement after executing it:

db.commit()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.