MySQLdb is a Python Database API Specification 2.0 database module, so you should be familiar with the spec. Deviations from the spec are documented in the MySQLdb documentation.
MySQLdb now supports transactions if the server supports transaction-safe tables (TSTs) and you are using them. If your server doesn't support them, rollbacks will always fail, as they should, because it can't do what you asked. Even if your server does support them, rollbacks will fail if you modified any non-TST tables.
OTOH, cursor.commit()
, which attempts to commit the
transaction to the database, always succeeds, because MySQL
essentially is always in auto-commit mode (unless you told it
otherwise).
First answer: Don't, if you can avoid it. Your program will not be portable to other databases.
Second answer: Nearly all the special API calls are implemented on the _mysql connection object, and the MySQLdb connection object can also invoke them. See the built-in module docs to find out what ones are implemented, and the MySQL C API docs to see what they do.
Well, it may
be appropriate in some cirumstances. ZMySQLDA
does this, because Zope's ZRDB module is an API in itself, and too
many layers of APIs tend to make a mess of things. Besides, it was
actually pretty easy to do it that way and it probably improves the
performance a bit.