Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#882 closed defect (fixed)

"django-admin sqlclear" fails with sqlite3

Reported by: ye7cakf02@… Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: dev
Severity: major Keywords: sqlite3 unfinalised cursor close
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

$ django-admin sqlclear test
BEGIN;
Traceback (most recent call last):
  File "/home/nisse/bin/django-admin", line 139, in ?
    main()
  File "/home/nisse/bin/django-admin", line 132, in main
    output = ACTION_MAPPING[action](mod)
  File "/home/nisse/opt/python-2.4.2/lib/python2.4/site-packages/django/core/management.py", line 190, in get_sql_delete
    db.db.close()
  File "/home/nisse/opt/python-2.4.2/lib/python2.4/site-packages/django/core/db/backends/sqlite3.py", line 55, in close
    self.connection.close()
pysqlite2.dbapi2.OperationalError: Unable to close due to unfinalised statements

This is with the latest SVN django and pysqlite-2.0.5.
According to http://lists.initd.org/pipermail/pysqlite/2005-August/000129.html the problem appears when you're closing your database connection without first closing your cursor. Thus, a simple fix is to add the line:

   cursor.close()

To the file management.py on the line before the one that triggers the exception (see traceback).
This probably won't fix all the cases but it sure solves my problem.

Change History (1)

comment:1 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

(In [1429]) Fixed #882 -- Fixed bug when doing django-admin.py sqlclear with SQLite. Thanks, ye7cakf02

Note: See TracTickets for help on using tickets.
Back to Top