Working with cursors in mysql-python I called "BEGIN;", "COMMIT;" and "ROLLBACK"; explicitly as follows:
try: cursor.execute("BEGIN;") # some statements cursor.execute("COMMIT;") except: cursor.execute("ROLLBACK;")
it turned out that the base connection object has the appropriate methods:
try: cursor.connection.begin() # some statements cursor.connection.commit() except: cursor.connection.rollback()
Checking DB-API PEP I found out that it does not mention the begin () method for the connection object, even for the extension.
Mysql-python, by the way, throws the DeprecationWarning method when you use this method. sqlite3.connection, for example, has no method at all.
And the question is, why is there no such method in PEP? Is the statement somehow optional, is it enough to call commit ()?
python sql python-db-api
newtover
source share