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
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
>>
> -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,
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
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
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
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
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-
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
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
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
>
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
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:
13 matches
Mail list logo