#4427: daily_cleanup.py should use database API
-----------------------------------+----------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: jacob
Status: new | Component: Uncategorized
Version: SVN | Keywords:
Stage: Unreviewed | Has_patch: 0
-----------------------------------+----------------------------------------
The {{{django/bin/daily_cleanup.py}}} script currently uses custom SQL to
delete expired session objects. I think it would be neater to use the
database API to bulk delete the query set.
For example:
{{{
cursor = connection.cursor()
cursor.execute("DELETE FROM %s WHERE %s < NOW()" % \
(backend.quote_name('django_session'),
backend.quote_name('expire_date')))
}}}
would become:
{{{
Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()
}}}
This also has the additional benefit of working in SQLite, whereas with
the custom SQL I get the error:
{{{sqlite3.OperationalError: no such function: NOW}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/4427>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---