[DB-SIG] Python 2.0 DB Api - Threading and Transactions not known until connected

M.-A. Lemburg mal@lemburg.com
Fri, 27 Aug 1999 09:41:08 +0200


Brad Clements wrote:
> 
> On 26 Aug 99, at 16:05, M.-A. Lemburg wrote:
> 
> > > 4. Since the 2.0 DB spec says "auto-commit must be initially disabled",
> > > then I'll never call ADO.CommitTrans unless the user calls
> > > connection.commit(). Therefore everything the user does on the
> > > connection is one huge transaction, right?
> >
> > No, you call CommitTrans when the user calls connection.commit()
> > and RollbackTrans when he calls connection.close() or deletes
> > the connection object.
> 
> So, if the user never calls connection.commit, then *all* his changes are
> one giant transaction?

Right, if he never calls .commit() then all his changes are
considered one transaction and even more: since the connection
close invokes the .rollback() method he will never see his changes
in the database (just a few days ago someone mailed me about such
a "problem" with mxODBC).

> I must be a dunce. What's confusing me is that the spec says "auto-
> commit must be disabled", yet somehow you're saying I should auto-
> commit when he closes the connection. yet I thought you said I should
> rollback if he didn't call commit.

Heh ? I said the close should do an implicit .rollback(). This
is the safe way. An implicit .commit() could destroy data !
 
> How can a user use the my DB if they never call commit? (say, they're
> doing very simple stuff and don't think of it). Then I'll never call commit?

Right. Transactions are under user control and should not
be committed automatically.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Y2000:                                                   127 days left
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/