This works well.
I guess I failed to clarify:  2. Is there a way of following this example
but deleting rows upto a certain limit, say anything above 50 like in this
example:...

Should have been retain latest inputs up a certain limit e.g. the last
50, and delete older inputs.

I got a better deal, maybe:


older = request.now - datetime.timedelta(days=1)
db(db.post.modified_on < yesterday).delete()

On Sun, Jul 22, 2018 at 9:40 PM Anthony <abasta...@gmail.com> wrote:

> On Sunday, July 22, 2018 at 7:13:13 AM UTC-4, Maurice Waka wrote:
>>
>> I have tried this example but I get this error below:
>>
>>
>> db(query).delete()
>>
>>
> Show the code for "query". Looks like it might include a Set object where
> a field or value is expected.
>
>
>> DELETE FROM post WHERE id IN(SELECT id FROM post ORDER BY id LIMIT 50 ASC)
>>
>>
> Does this work?
>
> first_fifty_posts = db(db.post)._select(db.post.id, orderby=db.post.id,
> limitby=(0, 50))
> db(db.post.id.belongs(first_fifty_posts)).delete()
>
> See "nested selects" at
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#belongs
> .
>
> Anthony
>
>> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/LPxSiL3u0MI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to