Provide a way of allowing autocommit
MySQL database connector for Python programming
Brought to you by:
adustman
I realise that the DB-API says that MySQLdb has to disable autocommit by default, however due to recent changes in MySQL whereby this breaks things even with MyISAM tables, this behaviour of MySQLdb has become not only backwards-incompatible, but extremely inconvenient indeed.
Could you please add a keyword parameter to MySQLdb.connect (off by default of course) which, if enabled, prevents MySQLdb from calling autocommit() automatically.
I realise also that people can call autocommit() manually on every connection, however for various reasons this is not at all convenient. In my application I have had to make a fake 'MySQLdb' module which imports the real module and then overwrites the connect() method.
What "recent changes in MySQL" are you referring to? Otherwise, no.
I mean that until recently, if you were only using MyISAM tables then the 'autocommit' status made no difference. However, in 5.5, if you use any DDL statements (including read-only ones such as DESCRIBE), your MyISAM tables end up getting wedged in 'Waiting for metadata lock' state.
It took me quite a while to discover the cause of this, as it was extremely surprising to me that mysql-python was secretly sending unexpected SQL commands behind the scenes, not to menion that the non-transactional MyISAM tables now have interactions with transactions.
Besides, why on earth would you say "no" to this change request? It is utterly trivial, would not break anything, and offers useful functionality. You already have various other options to the connect() method.
It was a "wont-fix" because you didn't provide any information about why disabling autocommit at the start was an issue ("breaks things" is insufficient). I'd still like to see a reference somewhere (preferably the MySQL documentation) about this before I decide how to handle it, and whether or not this is a bug in MySQL or expected behavior.
Found: http://bugs.mysql.com/bug.php?id=61391
See also: http://dev.mysql.com/doc/refman/5.5/en/metadata-locking.html
The change appears to be deliberate, and is documented. It means that applications that have been working fine for many years with MySQL and mysql-python will suddenly stop working (in a way that may well be very hard to consistently repeat or diagnose). Personally I regard this as a bug in MySQL 5.5 but I don't expect they will agree.