Getting benifits of database transactions in an OO way?

Leif K-Brooks eurleif at
Sat Aug 21 23:22:35 EDT 2004

Paul Rubin wrote:
> Leif K-Brooks <eurleif at> writes:
>>How woould begin_transaction() and finish_transaction() be
>>implemented? They couldn't be simple wrappers for PostgreSQL
>>transaction handling, since it's not very object-oriented (the whole
>>connection has one transaction at a time).
> Yes, if you want multiple concurrent transactions, you need separate
> connections for them.

But then multiple row classes would have to create their own 
connections, which would be bad for performance:

import people
import companies
people_transaction = people.begin_transaction()
companies_transaction = companies.begin_transaction()
microsoft = companies_transaction.find_by_name('Microsoft')
bill = people_transaction.find_by_name("Bill Gates") += 1000000

I think I'll just require users of modules which handle data to commit 
on their own. Not ideal, but it seems to be the best possible.

More information about the Python-list mailing list