> > query has a count() method as well. > > Then, what is a way to know the count in situations like this? > > persons = Person.select_by(surname='Patel') > row_count = persons.count() # produces error as > persons is a list object >
see: http://www.sqlalchemy.org/docs/sqlalchemy_orm.html#docstrings_sqlalchemy.orm_Query -- look for the method count_by(). On May 14, 11:45 pm, Sanjay <[EMAIL PROTECTED]> wrote: > > >> a. Observed that SelectResults was having a count() method. If we > > >> don't use SelectResults, either we have to query the database for > > >> getting the count manually, or use len(list). Using 'len' may not be > > >> recommended in paginated data grids. > > > query has a count() method as well. > > Then, what is a way to know the count in situations like this? > > persons = Person.select_by(surname='Patel') > row_count = persons.count() # produces error as > persons is a list object > > > >> b. Seeing the TurboGears code for 'paginate', it checks for the type > > >> of variable. If it is a list, it just applies len(list)! Does that > > >> mean, we have to explicitly use SelectResults with TurboGears? > > > Pylons has taken this issue into account with its own paginage function: > > >http://pylonshq.com/docs/0.9.5/module-webhelpers.pagination.html > > > the size of the list is passed separately (which is typically > > achieved via a single count() call), if not present uses len(list). > > TG should follow this example. > > Started some discussion in TG group on this. Is there any plan to drop > SelectResults from SQLAlchemy before TG is taken care, it might create > some problem to user like me. > > > this was a small bug that was fixed in trunk a few weeks ago. > > SelectResults is deprecated anyway and its easier to use query directly. > > A near future release covers this? > > thanks > Sanjay --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
