On Monday, October 7, 2013 11:34:53 PM UTC-7, Niphlod wrote:
>
> 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
>

Well, working with a DB with even just 20000 entries is a new experience 
for me (in the classroom, 40 entries is a big virtual supermarket)  :-}

 

> 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)
>

I should be able to learn a little more from this example  :-D

/dps
 

>
> 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.

Reply via email to