On Dec 3, 2007 7:57 AM, placid <[EMAIL PROTECTED]> wrote:
>
> Hi All,
>
> I'm trying to write a function that only runs (automatically) every
> two weeks that will just archive some rows in the database to another
> table. So far this is what i have (which doesn't work, i get a
> KeyError exception on the line were i try to do the select )
>
> import web,threading,time
>
> def archiver():
>      while True:
>           data = web.select('data',where='finish_data <= '14'))
>           # do stuff with data
>           #time.sleep(1209600), for testing purposes use 10 second
> intervals
>           time.sleep(10)
>
>
> if __name__ == '__main__':
>
>     web.config.db_parameters = dict(dbn='mysql', user='user',
> pw='password', db='mydatabse')
>
>     # start archiver thread
>     archiver_thread =
> threading.Thread(target=archiver,name='archiver_thread')
>     archiver_thread.setDaemon(True)
>     archiver_thread.start()
>
>     web.run(urls, globals(), web.reloader)

You need to call web.load() in the begining of archiver() function.
I think, it is better to use cron to run the script regularly than
running it using sleep in the function.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to