By default, SqlAlchemy has `expire_on_commit=True`. 

I'm going to poorly restate most of what Mike Bayer has told me in the 
past:  the rationale behind this- an active Session is supposed to mirror 
the current state in the database; within a transaction we know the object 
values are equal to the table values.  Once the transaction ends via 
`commit`, the object is no longer in sync - another transaction may have 
modified that database row.  

In your example, note these 2 lines from the stacktrace:

File "sqlalchemy/orm/attributes.py", line 669, in get
  value = state._load_expired(state, passive)

when you invoked a `commit`, SqlAlchemy expired the object (after the 
commit).

when you invoked `print()`, SqlAclhemy recognized the object as expired and 
is now trying to load the expired attributes so it can print them for you.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/bdb5dde6-ff15-472d-a3da-4aa5b980fdfc%40googlegroups.com.

Reply via email to