[Twisted-Python] adbapi transaction stuff (was Re: twisted.news adbapi backend)

Stephen C. Waterbury golux at comcast.net
Fri Sep 26 07:36:46 MDT 2003


Hi Jp,

Jp Calderone wrote:
> On Thu, Sep 25, 2003 at 10:55:01PM -0400, Stephen C. Waterbury wrote:

>>... but PostgreSQL doesn't implement a COALESCE command.
>>
>   I was surprised to read that PostgreSQL doesn't implement COALESCE, so I
> checked the docs.  They claim it has been supported since 6.5.  Are you
> running an expecially old version? :)

Hm ... you mean I should actually check to see if it works
before assuming it's not there?  Doh!  I was going by the
fact that the psql \h didn't have anything on it, but
you're absolutely right -- it's there and works as
advertised.  (I guess \h only documents the big, top-level
commands -- not functions/expressions.)

>   It's probably not great database code.  Deprecating it now and removing it
> in a while sounds like a good idea.

I don't think it looks bad, really ... just seemed like
it had never been used.

Actually, the only reason I was looking at it was that it
was the only example I could find of code that used the adbapi
runInteraction() and transaction stuff, so it looked like
it might be useful to me at first, but I couldn't figure
out how to get a Transaction to do a "SET CONSTRAINTS
ALL DEFERRED", which I need for my transactions.
(I did it in the transaction.execute(), but it didn't
seem to have any effect, so I wasn't sure if it really
applied ... I assume they are supposed to, for a
given runInteraction scope, right?)

Anyway, I went ahead and made a "transaction builder" that
puts together a whole SQL transaction statement that I can
give to runOperation, and that seems to work just fine --
which might actually be easier and faster anyway, since it
lets PostgreSQL do its own optimization things, etc.

Still, the adbapi transaction stuff is intriguing,
so let me know if I'm missing something there -- e.g.,
if you know how to use it to do an SQL transaction with
deferred constraints.  What I was hoping it did was
incrementally execute stuff and just commit when the
runInteraction call ended.

Cheers,
Steve.





More information about the Twisted-Python mailing list