MySQLdb: commit before cursor close, or after?

John Nagle nagle at animats.com
Mon Feb 4 13:14:13 EST 2008


   I'm getting some wierd commit-related behavior from MySQLdb.  I'm
using InnoDB, so transactions really matter.

I'm currently doing

	cursor = db.cursor()					
	cursor.execute(...)
	cursor.close()							
	db.commit()	

Is that the correct order, or should I call "db.commit()" before 
"cursor.close()"?  Does anyone know for sure?  The MySQLdb documentation
("http://mysql-python.sourceforge.net/MySQLdb.html") doesn't
say.  There are some discussions of this in blogs, but nobody
really seems to know.

					John Nagle						



More information about the Python-list mailing list