sql-wise, that query of yours will have to scan the entire table to find
records, because you're applying a function to a date. Even if you think to
put an index on logtime, the result won't change.
thanks to god, you have datetime in python :D
now_1 = request.now.date() - datetime.timedelta(days=1)
now_2 = request.now.date() - datetime.timedelta(days=2)
results = db(
(db.logtable.logtime < now_1) &
(db.logtable.logtime > now_2)
).select(orderby=~db.logtable.logtime)
On Tuesday, October 8, 2013 3:44:44 AM UTC+2, Dave S wrote:
>
> I have figured out that I'm interested in queries like
>
> results = db.executesql("SELECT * FROM logtable where logtime <
> date('now','-1 day') AND logtime > date('now','-2 days') ORDER BY logtime
> DESC") ;
>
>
> How would I rewrite that as DAL query?
>
> Thanks.
>
> /dps
>
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.