evorepo/scripts/daily_cleanup.py
eliott 39a548fd26 Initial import for public release...
Special Note
  Prior to git import, approx 90% of the code was done by Judd Vinet. Thanks Judd!
2007-11-03 03:45:10 -04:00

15 lines
538 B
Python

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()