I'm obviously missing some key concept as regards the management of sessions.
This seemingly simple usage fails:
def get_new():
sess = Session()
new = Something() # new orm object
sess.add(new)
sess.commit()
sess.close()
return new
new = get_new() # request a new Something
print new
print new.id
Those last 2 print lines throw:
DetachedInstanceError: Instance <Something at 0x2873ed0> is not bound to
a Session; attribute refresh operation cannot proceed
I seem to keep butting heads with the session needing to be a global eternal
thing (opposite what the docs recommend). I could create another session and
add 'new' to it, but that seems like a lot of boilerplate when all I wanted to
do was get a bit of info from the returned object.
Can someone explain how this is supposed to be done?
Thanks,
Michael
--
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.