Hi...I'm trying to run a delete statement... I've tried the same delete statement thru DB Designer, and it seems to work...I don't see any syntax errors errors...and it doesn't throw an exception...but the delete never occurs...do I have to call something after I call execute? The cursor is valid at this point in the code.
try:
cursor.execute ("DELETE FROM mytable WHERE id=4")
except MySQLdb.Error, e:
print "Error %d: %s" % (e.args[0], e.args[1])
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi...I'm trying to run a delete statement... I've tried the same delete statement thru DB Designer, and it seems to work...I don't see any syntax errors errors...and it doesn't throw an exception...but the delete never occurs...do I have to call something after I call execute? The cursor is valid at this point in the code.
try:
cursor.execute ("DELETE FROM mytable WHERE id=4")
except MySQLdb.Error, e:
print "Error %d: %s" % (e.args[0], e.args[1])
Stock answer: Autocommit is OFF by default. Do this after executing your statement:
db.commit()
where db is your database connection object.