I read in docs :
... because transactions begin when the cursor executes the query, but ends when COMMIT or ROLLBACK are executed using the Connection Object.
import MySQLdb db = MySQLdb.connect(user="root", db="test") c = db.cursor() c.execute("SELECT * FROM books") print c.fetchall()
I suspect that MySQLdb starts a transaction even on queries that do not change data (e.g. SELECT), because it is difficult to know if the query only reads the data and does not write them.
cursor.commit()
thank
, SELECT , .
SELECT
, - :
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ; SELECT * FROM books ; COMMIT ;
:
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;
, , , COMMIT. .
COMMIT
SELECT * FROM books ;, , a SQL statement, COMMIT ; "". , COMMIT
SELECT * FROM books ;
SQL statement
COMMIT ;
, , , mysql autocommit=1
autocommit=1
, SELECT . .
: DB-API Python & begin " ?