Code

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#882 closed defect (fixed)

"django-admin sqlclear" fails with sqlite3

Reported by: ye7cakf02@… Owned by: adrian
Component: Database layer (models, ORM) Version: master
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: UI/UX:

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.

Attachments (0)

Change History (1)

comment:1 Changed 8 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.