On Feb 4, 2008, at 4:01 PM, Felix Schwarz wrote:

>
> jason kirtland wrote:
>> SA won't automatically commit a transaction you've begun.  You need  
>> to .commit() explicitly.  As Michael said, .commit() will flush  
>> changes in the session before committing, so you could switch to  
>> calling that.
>> It can be useful in a transaction to issue a simple .flush().  It  
>> updates the database with the Python-side changes queued up in the  
>> unit of work, and those updated rows are visible to subsequent  
>> queries within the transaction.  The changes won't be visible to  
>> other db users until (and if) the transaction is eventually  
>> committed.
>
> Thank you very much for your detailed explanation! Now I do  
> understand why my session.flush() did not work.
>
> But (from unitofwork.py)
> def flush(...):
> ...
>        session.create_transaction(autoflush=False)
>        flush_context.transaction = session.transaction
>        try:
>            flush_context.execute()
>       ...
>        except:
>            session.rollback()
>            raise
>        session.commit()
>
> So I thought that flush should issue a commit?
>

that commit is nested within the transaction you've begun.  if you say:

session.begin()
session.begin()
session.commit()
session.commit()

it's the outermost begin/commit pair that defines the transaction.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to