mirror of
https://github.com/django/django.git
synced 2025-01-03 15:06:09 +00:00
Fixed #2748 -- Turned daily_cleanup.py into something that will run against the
current version of Django. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3860 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
cb829267b8
commit
1f8cc30f5f
@ -1,16 +1,17 @@
|
|||||||
"Daily cleanup file"
|
"""
|
||||||
|
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
|
from django.db import backend, connection, transaction
|
||||||
|
|
||||||
DOCUMENTATION_DIRECTORY = '/home/html/documentation/'
|
|
||||||
|
|
||||||
def clean_up():
|
def clean_up():
|
||||||
# Clean up old database records
|
# Clean up old database records
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
cursor.execute("DELETE FROM %s WHERE %s < NOW()" % \
|
cursor.execute("DELETE FROM %s WHERE %s < NOW()" % \
|
||||||
(backend.quote_name('core_sessions'), backend.quote_name('expire_date')))
|
(backend.quote_name('django_session'), backend.quote_name('expire_date')))
|
||||||
cursor.execute("DELETE FROM %s WHERE %s < NOW() - INTERVAL '1 week'" % \
|
|
||||||
(backend.quote_name('registration_challenges'), backend.quote_name('request_date')))
|
|
||||||
transaction.commit_unless_managed()
|
transaction.commit_unless_managed()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user