[sqlalchemy] Re: aggregation with count and webhelpers.paginate

2009-06-26 Thread Hollister
ooglegroups.com] On Behalf Of Hollister > >> Sent: 20 June 2009 02:15 > >> To: sqlalchemy > >> Subject: [sqlalchemy] Re: aggregation with count and > >> webhelpers.paginate > > >> Well, that worked great: > > >>     q = meta.Session.query(m.Hit

[sqlalchemy] Re: aggregation with count and webhelpers.paginate

2009-06-22 Thread Bobby Impollonia
g Simon-NFHD78 wrote: > >> -Original Message- >> From: sqlalchemy@googlegroups.com >> [mailto:sqlalch...@googlegroups.com] On Behalf Of Hollister >> Sent: 20 June 2009 02:15 >> To: sqlalchemy >> Subject: [sqlalchemy] Re: aggregation with count and >>

[sqlalchemy] Re: aggregation with count and webhelpers.paginate

2009-06-22 Thread King Simon-NFHD78
> -Original Message- > From: sqlalchemy@googlegroups.com > [mailto:sqlalch...@googlegroups.com] On Behalf Of Hollister > Sent: 20 June 2009 02:15 > To: sqlalchemy > Subject: [sqlalchemy] Re: aggregation with count and > webhelpers.paginate > > > Well,

[sqlalchemy] Re: aggregation with count and webhelpers.paginate

2009-06-19 Thread Hollister
Well, that worked great: q = meta.Session.query(m.Hit.referer, func.count(m.Hit.id))\ .group_by(m.Hit.referer)\ .order_by(func.count(m.Hit.id).desc()) Thanks! ps: Is there a better way to specify the count in the order_by? On Jun 19, 2:58 pm, "Michael Bayer" wrote: > Holli

[sqlalchemy] Re: aggregation with count and webhelpers.paginate

2009-06-19 Thread Michael Bayer
Hollister wrote: > > Ok, I see. > So what's the best way for me to construct and execute this query? use Query: session.query(MyClass.someid, MyClass.somethingelse).filter(..whatever..).order_by(..whatever...) > > On Jun 19, 1:30 pm, "Michael Bayer" wrote: >> you can't call count() when you

[sqlalchemy] Re: aggregation with count and webhelpers.paginate

2009-06-19 Thread Hollister
Ok, I see. So what's the best way for me to construct and execute this query? On Jun 19, 1:30 pm, "Michael Bayer" wrote: > you can't call count() when you've used from_statement, that should be > raising an error.   the bug is that no error is being raised. > > Hollister wrote: > > > Here you go

[sqlalchemy] Re: aggregation with count and webhelpers.paginate

2009-06-19 Thread Michael Bayer
you can't call count() when you've used from_statement, that should be raising an error. the bug is that no error is being raised. Hollister wrote: > > Here you go: > > URL: http://dev:5000/hits/referrers > File '/home/aw/venv/dev/lib/python2.6/site-packages/WebError-0.10.1- > py2.6.egg/weberro

[sqlalchemy] Re: aggregation with count and webhelpers.paginate

2009-06-19 Thread Hollister
Here you go: URL: http://dev:5000/hits/referrers File '/home/aw/venv/dev/lib/python2.6/site-packages/WebError-0.10.1- py2.6.egg/weberror/evalexception.py', line 431 in respond app_iter = self.application(environ, detect_start_response) File '/home/aw/venv/dev/lib/python2.6/site-packages/Beaker-

[sqlalchemy] Re: aggregation with count and webhelpers.paginate

2009-06-19 Thread Michael Bayer
oh. if the paginator uses slices to provide LIMIT/OFFSET, you need to construct a Query that can be limited via slice. don't use select() here, use Query fully. Hollister wrote: > > The bad news with "results = meta.Session.execute(s).fetchall()" is > that it runs for every page in the pagina

[sqlalchemy] Re: aggregation with count and webhelpers.paginate

2009-06-19 Thread Michael Bayer
seems like you need to use LIMIT/OFFSET to limit the results of your query. a paginator object should have some method of providing hooks for this. Hollister wrote: > > The bad news with "results = meta.Session.execute(s).fetchall()" is > that it runs for every page in the paginator, fetching a

[sqlalchemy] Re: aggregation with count and webhelpers.paginate

2009-06-19 Thread Michael Bayer
Hollister wrote: >> >> When I run this, I get: >> >> Module sqlalchemy.orm.query:1956 in setup_context >> <<          context.froms.append(self.selectable) >>                if context.order_by is False and self.mapper.order_by: >>                    context.order_by = self.mapper.order_by>>  if >

[sqlalchemy] Re: aggregation with count and webhelpers.paginate

2009-06-19 Thread Hollister
The bad news with "results = meta.Session.execute(s).fetchall()" is that it runs for every page in the paginator, fetching all rows each time. Thoughts, anyone? On Jun 19, 12:17 pm, Hollister wrote: > Update: > > If I run: >     results = meta.Session.execute(s).fetchall() > and pass that to pa

[sqlalchemy] Re: aggregation with count and webhelpers.paginate

2009-06-19 Thread Hollister
Update: If I run: results = meta.Session.execute(s).fetchall() and pass that to paginate, it works. I guess I just needed the ResultProxy, and not a collection of mapped objects. Mike, if you have any additional insight for me, I would appreciate it. On Jun 19, 11:30 am, Hollister wrote: