import spyce, scheduler
def delete_unsubmitted():
db = spyce.SPYCE_GLOBALS['dbpool'].connection()
sql = "DELETE FROM alerts WHERE status = 'unsubmitted' AND created < now() - '1 week'::interval"
db.execute(sql)
# delete alerts that were created over a week ago but but still not submitted
scheduler.schedule_daily(00, 10, delete_unsubmitted)
|