On Jan 30, 2012, at 12:07 PM, Joril wrote:

> On Jan 30, 5:02 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
> 
>> What's happening above is the session is not in a transaction due to 
>> autocommit, so when you call session.connection(), that connection is thrown 
>> away as far as the Session is concerned.   If you wanted to do it the 
>> "external" way like that, you need to set session.bind = connection, then 
>> the Session will do everything in terms of that connection.  You could skip 
>> the autocommit/begin/flush and just do a single session.commit(), which from 
>> the tx point of view would not be the actual commit.
>> 
>> Session has a public API for this, though it doesn't at the moment accept 
>> the XID, but you can grab the one it generates:
>> 
>> session = sessionmaker(engine)
>> session.prepare()
>> session.add(obj1)
>> session.flush()
> 
> The prepare() should be called _before_ issuing changes to the DB?

oh....sorry no I got that backwards.   Should be at the end, yes.


> I
> thought it was a substitute for the first commit()... Anyway, so after
> the flush the transaction will be in a "prepared" state and waiting
> for the COMMIT PREPARED? I'll try it, thanks :)
> 
>> either way should work, but turning on SQL echo is the best way to see what 
>> is/is not happening.
> 
> Yes I have echo active but it looks like I misunderstood the sequence
> of commands to give :/
> 
> Many thanks for your time!
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to