I’m using MySQLdb module for Python to make some simple queries. When I do a certain UPDATE, it hangs for a while and finally gives this error:
operational error (1205 ‘lock wait timeout exceeded try restarting
transaction’)
The code I’m using is the following:
def unselectAll():
try:
db = MySQLdb.connect(host='localhost', user='user', passwd='', db='mydatabase')
cursor = db.cursor()
cursor.execute('UPDATE MYTABLE SET Selected=0')
except MySQLdb.Error, e:
print 'ERROR ' + e.args[0] + ': ' + e.args[1]
If I try to use that query in console, works perfectly. Also, if connecting without db parameter and using mydatabase.MYTABLE at the query doesn’t work either.
Any help?
This could be because the
UPDATEisn’t getting commited – have you triedautocommit=Truefor the connection? As inor maybe even
after you’ve created the connection.