Menu

Problem with Delete

Help
carolez
2006-01-04
2012-09-19
  • carolez

    carolez - 2006-01-04

    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])

     
    • Andy Dustman

      Andy Dustman - 2006-01-04

      Stock answer: Autocommit is OFF by default. Do this after executing your statement:

      db.commit()

      where db is your database connection object.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.