> On 15 Mar 2016, at 22:13, Cecilio Ruiz <[email protected]> wrote: > > Hi ! > > Assuming this result: > > n = session.query(xx).all() > > > How I can find the id 5 on the 'n' ? > something like that.: > > v = n.get(5)
When you call “all()”, you’ve already loaded all the rows from the database into Python. “n” is just a Python list at this point. To load an object given its primary key you can use: v = session.query(xx).get(5) This checks the session first to see if the object has already been loaded. If it hasn’t, it will query the database. Hope that helps, Simon -- 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.
