the usual, they load on access.....you can do something in a commit event, i suppose. seems like an odd use case.
On Jan 14, 2013, at 7:30 PM, espresso maker wrote: > Ah got it. I'll go ahead with this approach and see how it goes. Is there a > way to load all relationships of the object once it's created in the db as a > result of a commit() ? > > On Monday, January 14, 2013 4:10:00 PM UTC-8, Michael Bayer wrote: > you can attach an object to a session at any time: > > > session.add(obj) > > > if the object is still associated elsewhere, or is to be associated with many > sessions, you can merge its state into a session, and if the object is > "clean", that is has no pending changes, you can specify load=False which > will disable any SQL and fully replace any existing version of the object: > > object_to_use = session.merge(obj, load=False) > > remember to use the returned object with merge(). > > > On Jan 14, 2013, at 6:17 PM, espresso maker wrote: > >> I have a daemon that is using sqlalchemy ORM to talk to the DB. One of the >> things it does is create an instance of a model, assign some values to it, >> add it to the session and commit. But I want to >> continue using this object later (and it's relations) without going back to >> the db after the commit. Moreover, at a certain point I need to apply >> additional changes to the created obj and commit it then continue reusing >> it. Is that possible without reloading the object from DB? I am always >> running into obj not in session issues, and after commit, relationships are >> retrieved again from db which I want to avoid because in reality they might >> have been deleted via the web app but I still want the daemon to access them >> until the created obj gets into a certain state. >> >> >> -- >> 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/-/F1lfiiDM41sJ. >> 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. > > > -- > 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/-/qLjsiCVghCYJ. > 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. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. 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.
