There are some hints for keeping references to objects at: http://docs.sqlalchemy.org/en/latest/orm/session_state_management.html#session-referencing-behavior
Simon On Thu, Jul 21, 2016 at 5:11 PM, Mehdi gmira <[email protected]> wrote: > Yeah I thought of that. I find it awkward because you have to think of using > threadlocal objects, etc. I would have liked it better if sqlachemy exposed > an api for that. But if that's not the case I'll do that. > > > Le jeudi 21 juillet 2016 17:56:45 UTC+2, Jonathan Vanasco a écrit : >> >> I do this often. >> >> All you need to do it stash the object into something that is in the scope >> you wish the object to survive. An array or dict works perfectly: >> >> stashed = [] >> >> >> def f(s): >> ... >> parents = s.query(Parent).all() # load all parents objects in identity >> map >> stashed.append(parents) >> >> >> In the case of web programming, I stash loaded objects onto the `request` >> object. > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
