Have you tried adding a db.commit() to your delete_after_hours() function?

-Jim



On Tuesday, October 5, 2021 at 8:49:44 AM UTC-5 Andrew wrote:

> Hello, I am trying to run a database query using the web2py scheduler, but 
> for some reason I can't get the query to commit. I've tested the function 
> in a controller to see that it works, and I'm pretty sure the scheduler is 
> running correctly because I have a scheduler_worker with the status of 
> ACTIVE in my backend.
>
> this is my *scheduler.py* in *models*:
>
> from gluon.scheduler import Scheduler
> scheduler = Scheduler(db)
>
> def delete_after_hours():
>     current_start = now
>     start = current_start.replace(tzinfo=utc)
>     rows = db(db.public_uploads.id > 0).select()
>     for row in rows:
>         end_time = row.end_time
>         end = end_time.replace(tzinfo=utc)
>         if start >= end:
>             row.delete_record()
>
> scheduler.queue_task(delete_after_hours)
>
>
> Thanks in advance for any advice.
>
> *cheers
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/bcf6429d-18af-4870-bc2b-8928f12aadedn%40googlegroups.com.

Reply via email to