summaryrefslogtreecommitdiffstats
path: root/google_appengine/lib/django/django/bin/daily_cleanup.py
blob: 3b83583d73ee27a29a2089f32f5720138bc88d00 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python

"""
Daily cleanup job.

Can be run as a cronjob to clean out old data from the database (only expired
sessions at the moment).
"""

from django.db import backend, connection, transaction

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')))
    transaction.commit_unless_managed()

if __name__ == "__main__":
    clean_up()