1 from django
.db
import backend
, connection
, transaction
3 This purges the session data that is old from the session table.
6 # Clean up old database records
7 cursor
= connection
.cursor()
8 cursor
.execute("DELETE FROM %s WHERE %s < NOW()" % \
9 (backend
.quote_name('django_session'), backend
.quote_name('expire_date')))
10 cursor
.execute("OPTIMIZE TABLE %s" % backend
.quote_name('django_session'))
11 transaction
.commit_unless_managed()
13 if __name__
== "__main__":