theres a "nesting" behavior to transactions, which is illustrated here:

http://www.sqlalchemy.org/docs/dbengine.html#using-transactions-with-connection

the setup/teardown thing I illustrated uses this functionality with a Session, 
so that the Session isn't actually committing the real transaction.   The 
session would take the place of "method_b()" in that example.


On Jun 29, 2010, at 5:15 AM, Chris Withers wrote:

> Just bumped into these questions which I still don't understand :-S
> 
> Chris Withers wrote:
>>> I use setup/teardowns like this for this purpose (assume scoped_session, 
>>> which yes you should probably use all the time so that the session is 
>>> accessed by a single reference):
>> Where do you actually drop/create the tables?
> 
>>> def setup_for_rollback():
>>>    Session.remove()
>> The docs on this are a little brief ;-)
>> http://www.sqlalchemy.org/docs/reference/orm/sessions.html#sqlalchemy.orm.scoping.ScopedSession.remove
>>  This seems key to your suggested strategy. What does it do?
> 
>>> def teardown_for_rollback():
>>>    transaction.rollback()
>>>    Session.remove()
>>>    above, "transaction" is the "real" transaction.  All begin/commits 
>>> inside don't actually commit anything.
>> Again, this last bit escapes me, how come Session().commit() or begin 
>> doesn't do anything?
> 
> cheers,
> 
> Chris
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalch...@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 sqlalch...@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