Python MySQLdb update query fails

后端 未结 2 1164
醉酒成梦
醉酒成梦 2020-12-10 13:41

Okay. I\'ve built here a mysql query browser, like navicat. Using MySQLdb to perform queries.

Here\'s the weird part. When i run the query through the program(using

相关标签:
2条回答
  • 2020-12-10 14:12

    I believe @Jason Creighton and @S.Lott are correct.

    At least if the table that you're updating is on a transactional storage engine. InnoDB is transactional, ISAM is not.

    You either have to call commit() on your connection object before closing it, or you must set the connection to autocommit mode. I am not sure how you do that for a MySQLdb connection, I guess you either set an argument to the connection constructor, or set a property after creating the connection object.

    Something like:

    conn = mysql.connection(host, port, autocommit=True)
    
    # or
    conn = mysql.connection(host, port)
    conn.autocommit(True)
    
    0 讨论(0)
  • 2020-12-10 14:13

    Just a guess: Perhaps the code in Python is running within a transaction, and the transaction might need to be explicitly committed?

    Edit: There's an entry in the MySQLdb FAQ that might be relevant.

    0 讨论(0)
提交回复
热议问题