Heston, Heston James wrote: > Werner, > > Thank you for your response, very kind of you. This looks to be more > what I'm looking for, after a quick test it seems that it is now > applying the limit at the SQL level which is definitly a good thing. > > Where abouts in the documentation did you find that? Look here: > http://www.sqlalchemy.org/docs/05/ormtutorial.html is seems to > reccomend the same method as reccomended by the first repsonder, is > that a fault in the docs perhaps? > It is from the api doc, see here: http://www.sqlalchemy.org/docs/05/sqlalchemy_orm_query.html
When I search for things on the doc page I mostly click first on the link in the top right "One page", unless I know which section contains what I am looking for. > The next challegne I've noticed with using Limit() is that it doesnt > appear to return an array of objects, but instead, a query object, so > when I try and perform an evaluation on it like so: > > if len(the_objects): > > I get an error which states: > > TypeError: object of type 'Query' has no len() > > Why is this? Does using Limit() mean that we're returning query > objects instead of the array of objects I was getting before? > Yes (now take my answer with a grain of salt, I am by no means an SA expert, nor even an advanced user). In the 0.5 version you can do things like: query = session.query(db.Mytable) query = query.order_by(....) query = query.limit(3) ... etc but then you need to tell it to actually get the data, with .first(), .one(), .all() or iterate over it, e.g. for aninstance in query: print aninstance Hope this helps, and if I said something wrong I hope someone corrects me. Werner --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---