MySQL Forums
Forum List  »  Connector/Python

Re: cursor close and db commit
Posted by: Geert Vanderkelen
Date: February 11, 2013 11:22AM

(1) It depends on the transaction isolation level. If you have the REPEATABLE
READ level set, which is default, the SELECT statement will always show the
same value if you query in a loop for example. If you do a commit after the
SELECT, the next time your execute the same query, it will see the changes.
Maybe you want to set the transaction level to READ COMMITTED for that
session then.

(2) If you do things sequencly, which is usually the case in web sessions,
it good ot open 1 connection and 1 cursor and do everything with that
cursor. Care that you commit when needed. Generally, the lesser operations
during a web session, the better.

(3) cnx.commit() before cur.close() sounds most logical to me.
Maybe you can go by the rule: "Close the cursor if you do not need it
anymore."
Thus commit() before closing the cursor. In the end, for Connector/Python,
it does not make much difference, but or other databases it might.

Geert Vanderkelen
Software Developer at Oracle

Options: ReplyQuote


Subject
Written By
Posted
February 09, 2013 02:53AM
Re: cursor close and db commit
February 11, 2013 11:22AM
February 13, 2013 02:20AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.