diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-06-01 09:46:56 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-06-01 09:46:56 +0000 |
| commit | 250b84dd0e30ae916e2f033790098281dff0b9e2 (patch) | |
| tree | 3d54d8ee2583941b8c0c7a65234a1f4a207a78b6 | |
| parent | a3b6e4e7d339ee2f1740962f42e182e025ce6615 (diff) | |
Fixed #4427 -- Ported daily_cleanup.py to use model API for greater
portability. Thanks, nick.lane.au@gmail.com.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5403 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | AUTHORS | 1 | ||||
| -rw-r--r-- | django/bin/daily_cleanup.py | 10 |
2 files changed, 6 insertions, 5 deletions
@@ -142,6 +142,7 @@ answer newbie questions, and generally made Django that much better: Joseph Kocherhans konrad@gwu.edu lakin.wecker@gmail.com + Nick Lane <nick.lane.au@gmail.com> Stuart Langridge <http://www.kryogenix.org/> Nicola Larosa <nico@teknico.net> Eugene Lazutkin <http://lazutkin.com/blog/> diff --git a/django/bin/daily_cleanup.py b/django/bin/daily_cleanup.py index 3b83583d73..c87be1e4c3 100644 --- a/django/bin/daily_cleanup.py +++ b/django/bin/daily_cleanup.py @@ -7,13 +7,13 @@ 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 +import datetime +from django.db import transaction +from django.contrib.sessions.models import Session 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'))) + """Clean up expired sessions.""" + Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete() transaction.commit_unless_managed() if __name__ == "__main__": |
