Well that means that i need to write a script that uses mysqldb and
not the nice api that web.py provides.

The purpose is not really 'backing up' just moving some data into a
separate
table so that it doesn't show up by default, but is still
searchable.

On Dec 3, 3:22 pm, bubblboy <[EMAIL PROTECTED]> wrote:
> placid wrote:
> > Thanks it works now.
>
> > Also why do you think that cron is better then the sleep function?
>
> > On Dec 3, 1:55 pm, "Anand Chitipothu" <[EMAIL PROTECTED]> wrote:
> >> 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.
>
> Simply because cron was /made/ for this kind of things :). Using threads
> generally does little more than make your unnecessarily complicated, by
> the way. You are using resources for something cron can perfectly
> handle. Basically, this solution has no advantages over simply using
> cron while cron has a lot of them: robust, logging, intuitive (other
> admins /expect/ cron, not this), etc etc etc. Also, might I add that if
> you want to create database backups you might be better off using a real
> tool, such as mysqldump, that was made for making backups (and does it
> well) as opposed to web.py, which is a webframework, not a database
> backup utility (at least not in the first place). That being said, I do
> agree that web.py's db module is very nice :)
>
> b^4
--~--~---------~--~----~------------~-------~--~----~
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