From 39a548fd2629f3b6383990264b2e331b3aea99fb Mon Sep 17 00:00:00 2001 From: eliott Date: Sat, 3 Nov 2007 03:45:10 -0400 Subject: Initial import for public release... Special Note Prior to git import, approx 90% of the code was done by Judd Vinet. Thanks Judd! --- scripts/daily_cleanup.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 scripts/daily_cleanup.py (limited to 'scripts/daily_cleanup.py') diff --git a/scripts/daily_cleanup.py b/scripts/daily_cleanup.py new file mode 100644 index 00000000..98f997bf --- /dev/null +++ b/scripts/daily_cleanup.py @@ -0,0 +1,14 @@ +from django.db import backend, connection, transaction +""" Daily cleanup file + This purges the session data that is old from the session table. +""" +def clean_up(): + # Clean up old database records + cursor = connection.cursor() + cursor.execute("DELETE FROM %s WHERE %s < NOW()" % \ + (backend.quote_name('django_session'), backend.quote_name('expire_date'))) + cursor.execute("OPTIMIZE TABLE %s" % backend.quote_name('django_session')) + transaction.commit_unless_managed() + +if __name__ == "__main__": + clean_up() -- cgit v1.2.3-54-g00ecf