Is it bad that I can already see WTFs in the making here?

  • My data disappeared! (or won't go away!)

    Starting with 1.2.0, MySQLdb disables autocommit by default, as required by the DB-API standard (PEP-249). If you are using InnoDB tables or some other type of transactional table type, you'll need to do connection.commit() before closing the connection, or else none of your changes will be written to the database.

    Conversely, you can also use connection.rollback() to throw away any changes you've made since the last commit.

    Important note: Some SQL statements -- specifically DDL statements like CREATE TABLE -- are non-transactional, so they can't be rolled back, and they cause pending transactions to commit.




    meaning of course that people will use create table statements and such to make sure their transactions are committed.....

  • I don't think they will. It seems like far too much trouble to become a common hack.

    But disabling autocommit by default, that's an annoying feature. I would say it's the "real wtf" here... (yes it might be the most correct behaviour, but it's not the most obvious behaviour, and I think that counts harder).

  • Filed under says it all

Log in to reply

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.