﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
882	"""django-admin sqlclear"" fails with sqlite3"	ye7cakf02@…	Adrian Holovaty	"{{{
$ 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.
"	defect	closed	Database layer (models, ORM)	dev	major	fixed	sqlite3 unfinalised cursor close		Unreviewed	0	0	0	0	0	0
