2005-07-13 09:25:57 +08:00
|
|
|
"Daily cleanup file"
|
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
from django.db import backend, connection, transaction
|
2005-07-13 09:25:57 +08:00
|
|
|
|
|
|
|
DOCUMENTATION_DIRECTORY = '/home/html/documentation/'
|
|
|
|
|
|
|
|
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-05-02 09:31:56 +08:00
|
|
|
(backend.quote_name('core_sessions'), backend.quote_name('expire_date')))
|
2005-11-14 09:44:35 +08:00
|
|
|
cursor.execute("DELETE FROM %s WHERE %s < NOW() - INTERVAL '1 week'" % \
|
2006-05-02 09:31:56 +08:00
|
|
|
(backend.quote_name('registration_challenges'), backend.quote_name('request_date')))
|
|
|
|
transaction.commit_unless_managed()
|
2005-07-13 09:25:57 +08:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
clean_up()
|