MySQLdb: commit before cursor close, or after?

Carsten Haese carsten at
Mon Feb 4 21:02:14 CET 2008

On Mon, 2008-02-04 at 19:53 +0100, Frank Aune wrote:
> No, you obviously need to commit your changes before closing the cursor. I'm 
> surprised if your code above even works if adding content to the db.

Why is that obvious? Is this some MySQL-specific oddity? In other
databases, it's the cursor's execute() method that adds the content to
the db (pending a commit of the transaction), and closing the cursor
simply means that you are explicitly releasing the resources that the
cursor used. Whether the cursor is closed before or after the
transaction is committed, or even whether the cursor is explicitly
closed at all or not, should make no difference whatsoever.

Carsten Haese

More information about the Python-list mailing list