2007-01-03 04:39:30 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2006-09-26 21:08:16 +08:00
|
|
|
"""
|
|
|
|
Daily cleanup job.
|
2005-07-13 09:25:57 +08:00
|
|
|
|
2006-09-26 21:08:16 +08:00
|
|
|
Can be run as a cronjob to clean out old data from the database (only expired
|
|
|
|
sessions at the moment).
|
|
|
|
"""
|
2005-07-13 09:25:57 +08:00
|
|
|
|
2006-09-26 21:08:16 +08:00
|
|
|
from django.db import backend, connection, transaction
|
2005-07-13 09:25:57 +08:00
|
|
|
|
|
|
|
def clean_up():
|
|
|
|
# Clean up old database records
|
2006-05-02 09:31:56 +08:00
|
|
|
cursor = connection.cursor()
|
2005-11-14 09:44:35 +08:00
|
|
|
cursor.execute("DELETE FROM %s WHERE %s < NOW()" % \
|
2006-09-26 21:08:16 +08:00
|
|
|
(backend.quote_name('django_session'), backend.quote_name('expire_date')))
|
2006-05-02 09:31:56 +08:00
|
|
|
transaction.commit_unless_managed()
|
2005-07-13 09:25:57 +08:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
clean_up()
|