Db transactions and locking
rosuav at gmail.com
Fri Nov 28 06:54:57 CET 2014
On Fri, Nov 28, 2014 at 4:44 PM, Frank Millman <frank at chagford.com> wrote:
> There seems to be a difference between conn.commit() and
> cur.execute('commit'), which leaves the connection in a different state.
Yes, if a connection library offers a way to commit/roll back, it's
usually best to use that.
> However, for my purposes, this is academic.
> The main lesson I have learned is that you should always issue a commit
> after any logical set of SQL statements, even if they are only SELECTs,
> otherwise the locks are not released.
Correct. Every time you use any database, you should think in terms of
units of work, which correspond precisely to transactions.
More information about the Python-list