﻿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
1311	'python manage.py sqlclear some_app' - fails to generate SQL when database is down	jakamkon@…	Adrian Holovaty	"edzio@infocrap:~/myproject$ python manage.py sqlclear sth

BEGIN;
Traceback (most recent call last):
  File ""manage.py"", line 11, in ?
    execute_manager(settings)
  File ""/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/management.py"", line 990, in execute_manager
    execute_from_command_line(action_mapping)
  File ""/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/management.py"", line 965, in execute_from_command_line
    output = action_mapping[action](mod)
  File ""/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/'''management.py'''"", '''line 193''', in '''get_sql_delete'''
    '''cursor.close()'''
AttributeError: ''''NoneType'''' object has no attribute 'close'
----
In management.py we have:

{{{
def get_sql_delete(mod):
...
    try:
        cursor = db.db.cursor()
    except:
        cursor = None
...
    cursor.close() # cursor = None when db is down
}}}
Solution:
{{{
   if cursor is not None:
       cursor.close()
       db.db.close()
}}}


"	defect	closed	Core (Other)	0.91	trivial	fixed	manage.py		Unreviewed	0	0	0	0	0	0
