[PEAK] _startDBTxn

Phillip J. Eby pje at telecommunity.com
Wed Apr 13 23:51:09 EDT 2005


At 05:06 PM 4/13/05 -0400, Erik Rose wrote:
>I thought I'd finished my ADOConnection class (which wraps an MS ADO data 
>source to present a PEAK ISQLConnection), but then I noticed the 
>_startDBTxn method, which SQLConnection's setTxnState calls. It seems like 
>I ought to implement it to call self.connection.begin(), but, OTOH, 
>PGSQLConnection doesn't define _startDBTxn at all. Is _startDBTxn 
>unnecessary, or is PGSQLConnection broken?

Neither, as far as I can recall.  :)  _startDBTxn() is used only for 
databases that don't enter transactions automatically.  IIRC, with 
PostgreSQL DBAPI adapters, when you commit or abort a transaction, a new 
one is automatically started.  Some databases call this "chained mode", and 
at least in theory this is supposed to be the default for DBAPI 2.0 adapters.

However, for Sybase and Oracle at least there are multiple transaction 
modes available and not all of them involve chaining, so sometimes explicit 
"begin" is necessary.  This is made particularly complex by the fact that 
Sybase has many operations that cannot be performed inside a 
transaction.  For example, you cannot create even a temporary table during 
a Sybase transaction.

So, you may or may not need a _startDBTxn() method depending on the 
transaction state transitions of the underlying DB.




More information about the PEAK mailing list