Opened 17 years ago
Closed 17 years ago
#4427 closed (fixed)
daily_cleanup.py should use database API
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Tools | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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
Attachments (3)
Change History (6)
by , 17 years ago
Attachment: | daily_cleanup.patch added |
---|
comment:1 by , 17 years ago
Summary: | daily_cleanup.py should use database API → [patch] daily_cleanup.py should use database API |
---|
Sorry about the first 2 patches.. I have no way to access subversion servers from where I am so I had to create the patch manually (and messed up twice doing so)
comment:2 by , 17 years ago
Component: | Uncategorized → Tools |
---|---|
Has patch: | set |
Owner: | changed from | to
Summary: | [patch] daily_cleanup.py should use database API → daily_cleanup.py should use database API |
Triage Stage: | Unreviewed → Ready for checkin |
This seems to me to be a fairly sensible choice, and it does fix a bug with SQLite.
comment:3 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Patch to use database API for daily_cleanup