its not built into Query() at the moment so the closest you could get  
would be query.from_statement(some_statement).   you can probably go  
from query->select()->back to query again doing something like this:

q = query.<build up your query>

session.query(...).from_statement(q.statement.prefix_with 
("SQL_CALC_FOUND_ROWS..."))



On Aug 29, 2009, at 2:47 AM, robert rottermann wrote:

>
> Michael Bayer schrieb:
>> use the "prefixes" argument to select() for this.
>>
> thanks very much.
> it it possible to use this somehow with session.query?
>
> I do not use select at all, but do construct the queries dynamically  
> like so:
>
>        q = session.query(tblNewsletteremail)
>        c = tblNewsletteremail.__table__.c
>        for k,v in info.items():
>            if isinstance(v, tuple):
>                op, v = v
>                if op == 'like':
>                    q = q.filter(c[k].like('%' + v + '%'))
>                if op == 'in':
>                    q = q.filter(c[k].in_(v))
>            else:
>                q = q.filter(c[k] == v)
>        if order_by:
>            for e in order_by:
>                q = q.order_by(c[e])
>        if limit:
>            q = q.limit(limit)
>        result = q.all()
> now I would like to "apply" SQL_CALC_FOUND_ROWS to the query object  
> before
> executing it. is this possible?
>
> thanks again
> robert
>
>>
>> On Aug 23, 2009, at 4:23 PM, robert rottermann wrote:
>>
>>> Hi there,
>>>
>>> I would like to create a batching functionality for a web based
>>> aplication that
>>> uses a mysql database.
>>>
>>> mysql offeres SQL_CALC_FOUND_ROWS for this purpose.
>>> how can I use it, or is there a generic way to have sqlalchemy
>>> return the number
>>> of rows a query would have returned without limit.
>>>
>>> thanks
>>> robert
>>>
>>
>>
>>>
>>
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to