not sure if the example was clear enough.
What I'm trying to do is to convert the following select to a mapped-
class:
select id, usr_id, rating,
( select COUNT(*) from ratings as r where r.id = ratings.id ),
( select AVG(r.rating) from ratings as r where r.id =
ratings.id)
Bj wrote:
not sure if the example was clear enough.
What I'm trying to do is to convert the following select to a mapped-
class:
select id, usr_id, rating,
( select COUNT(*) from ratings as r where r.id = ratings.id ),
( select AVG(r.rating) from ratings as r where r.id =
-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, that worked great:
q
...@motorola.com 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
webhelpers.paginate
Well, that worked great:
q
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
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 a.hollister.willi...@gmail.com wrote:
Update:
If I run:
results =
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
context.order_by
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 paginator,
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
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-
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 mike...@zzzcomputing.com 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
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 mike...@zzzcomputing.com wrote:
you can't call
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
[EMAIL PROTECTED] wrote:
hi, i have similar idea/need within dbcook, although on a somewhat
higher level:
pre
cache_results/: (dbcook/SA) add-on for automaticaly-updated database
denormalisation caches of intermediate results, each one depending on
particular pattern of usage. Wishful
On Wednesday 08 August 2007 12:18:24 Paul Colomiets wrote:
[EMAIL PROTECTED] wrote:
hi, i have similar idea/need within dbcook, although on a
somewhat higher level:
pre
cache_results/: (dbcook/SA) add-on for automaticaly-updated
database denormalisation caches of intermediate results,
Michael Bayer wrote:
i wonder though if theres some way that could get out of sync with
the actual number. you'd have to be careful to establish this
update. if you wanted to use a mapper extension to do it, then youd
have to issue the UPDATE directly, the change to the comment_count
On Aug 7, 1:20 pm, Paul Colomiets [EMAIL PROTECTED] wrote:
1. func.if_(...) - tries to sql function if_(...),
but func._if(...) - _i(...)
I believe is typo?
er, probably. func is trying to sidestep various _ underscore
attributes i think. do you need to say _if(...) ?
2. If there a
I've finally done first POC implementation of this feature.
Basic usage looks like:
import aggregator as a
mapper(Line, lines,
extension=a.Quick(a.Count(blocks.c.lines),
a.Max(blocks.c.lastline, lines.c.id)))
(You also need foreign keys)
hi, i have similar idea/need within
[EMAIL PROTECTED] wrote:=
http://www.mr-pc.kiev.ua/projects/SQLAlchemyAggregation
this gives me 404
Sorry:
http://www.mr-pc.kiev.ua/en/projects/SQLAlchemyAggregator
--~--~-~--~~~---~--~~
You received this message because you are subscribed to
Michael Bayer wrote:
On Aug 7, 1:20 pm, Paul Colomiets [EMAIL PROTECTED] wrote:
1. func.if_(...) - tries to sql function if_(...),
but func._if(...) - _i(...)
I believe is typo?
er, probably. func is trying to sidestep various _ underscore
attributes i think. do you need to say
Michael Bayer wrote:
Hmmm, do you mean joining relations against a subrelation that uses
an aggregate like MAX ? i'd like to see what you have in mind for this.
Well, I think I've not explained it correctly.
It looks quite like you're saying, but I want that aggregations
to be stored
On Aug 3, 2007, at 10:57 AM, Paul Colomiets wrote:
Michael Bayer wrote:
Hmmm, do you mean joining relations against a subrelation that uses
an aggregate like MAX ? i'd like to see what you have in mind for
this.
Well, I think I've not explained it correctly.
It looks quite like
On Aug 3, 2007, at 5:57 AM, Paul Colomiets wrote:
Hi,
Is there some aggregation ability built-in in the SQLAlchemy?
I want some simple functions like counting rows and determining the
last
one.
I know it's something simple to implement with Mapper Extensions,
but may be
there are
Michael Bayer wrote:
we've just added the atomic update thing to 0.4 (note the uppercase
Article which produces a column expression):
article.comment_count = Article.comment_count + 1
session.flush()
That's great!
It's quite unconvenient here, but has a lot of good use cases.
i wonder
24 matches
Mail list logo