Hi All,
I need to construct the following query:
select ADDDATE(start,INTERVAL rt_daily_days DAY) from _event where
repeat_type = 1;
and I have difficulties in dealing with the following statement:
INTERVAL rt_daily_days DAY,
how can I do this using sqlalchemy func interfaces?
Assuming I have a table
CREATE TABLE seq (i int auto_increment primary key, used bool default
false);
And want to query an mapped object from it which corresponds a query
SELECT i,used FROM seq WHERE NOT used AND i+1 IN (SELECT i FROM seq
WHERE AND used)
or (more or less equivalent)
SELECT
Thanks a lot for the tips on how to approach this problem. That's
exactly what I needed.
in 0.4 you'd get it off the impl (0.5 too, this is just uglier API):
Excellent! Here's what I came up with as an initial solution:
def poly_load(parent, collection, path):
def itersiblings(parent,
Alexander Kotelnikov wrote:
Assuming I have a table
CREATE TABLE seq (i int auto_increment primary key, used bool default
false);
And want to query an mapped object from it which corresponds a query
SELECT i,used FROM seq WHERE NOT used AND i+1 IN (SELECT i FROM seq
WHERE AND used)
or
millerdev wrote:
Thanks a lot for the tips on how to approach this problem. That's
exactly what I needed.
in 0.4 you'd get it off the impl (0.5 too, this is just uglier API):
Excellent! Here's what I came up with as an initial solution:
def poly_load(parent, collection, path):
def
I have a simple query with a group_by and count(), and I'd like to
pass this to webhelpers.paginate for display:
def referrers(self):
s = select([m.hit_table.c.id, m.hit_table.c.referer, func.count
(m.Hit.referer).label('count')],
from_obj = [m.hit_table],
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
Michael,
do you mean, that subqueries could not be wrapped into sqlalchemy?
what should be the arguments to join() I failed to figure out? how do
I reference different instances of seq in fileter() after?
Thanks,
A
On Jun 19, 7:43 am, Michael Bayer mike...@zzzcomputing.com wrote:
you can map
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
sacha wrote:
Michael,
do you mean, that subqueries could not be wrapped into sqlalchemy?
you talked about mapping to a select statement. mapping means this:
m = mapper(MyClass, someselectable)
mapping like the above is usually done against individual tables, and
usually once per class per
I really want to get a clear vision.
So, I have a table x and mapped class X.
I can use query(X) for simple queries, can I query(X) for structured
ones like
SELECT * FROM x WHERE x.a IN (SELECT )
?
Same about multi-cartesian product can I use query(X).join()
for SELECT * FROM x JOIN x
I meant SELECT x.* FROM x JOIN x AS x1 JOIN x AS x2 ... WHERE
On Jun 19, 1:55 pm, sacha sa...@myxomop.com wrote:
Same about multi-cartesian product can I use query(X).join()
for SELECT * FROM x JOIN x JOIN x .
?
--~--~-~--~~~---~--~~
You received
sacha wrote:
I really want to get a clear vision.
So, I have a table x and mapped class X.
I can use query(X) for simple queries, can I query(X) for structured
ones like
SELECT * FROM x WHERE x.a IN (SELECT )
sel = session.query(X.a).filter(X.b=='foo')
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
20 matches
Mail list logo