MySQLdb: commit before cursor close, or after?
Steve Holden
steve at holdenweb.com
Mon Feb 4 15:44:35 EST 2008
Carsten Haese wrote:
> 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.
>
Certainly isn't "obvious" to me. The whole point of the way
connection/cursor relationship is structured is to allow the possibility
of several cursors on the same connection. So cursors can be created,
used and closed at will without any effect on the underlying connection.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list
mailing list