Hello all,
my curious situation is the following. A very simplified version of the
code is:
for data in res:
obj = MyObject()
---here I fill the obj, aventually doing some query (create session,
get, close) to SA----
sess = createSession()
sess.add(obj)
sess.commit()
sess.close()
-- do some other query (create session, get, close) and eventually
persist the changes (create session, merge/add, commit close)
now... on the first loop it works fine, then I receive the "Parent
instance...." warning me that a an obj inner attribute, say a contact, is
not bound so cannot load contact.phone attribute. BTW I receive such
message when I commit() but I am able to make it appear looking in the
second loop, during a debugging session, at the specific obj attribute.
What I would like to implement is to restrict the "session" (in a more
general sense SA activity even if I know that actually SA inject some
instrumentation in obj at the creation time) inside a unique class, say
with some static methods (the code above involving the session is in a
separate class) in order to centralize the operation toward the DB, and
doing this it should act in a "stateless" way (createSession, do stuff,
commit/rollback, close), unfortunately seems that I am missing something.
Thanks
Maurizio
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sqlalchemy/-/J4THN4X57aUJ.
To post to this group, send email to [email protected].
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.