Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#1311 closed defect (fixed)

'python manage.py sqlclear some_app' - fails to generate SQL when database is down

Reported by: jakamkon@… Owned by: Adrian Holovaty
Component: Core (Other) Version: 0.91
Severity: trivial Keywords: manage.py
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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()

Change History (1)

comment:1 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

(In [2224]) Fixed #1311 -- manage.py sqlclear no longer assumes database connection is available. Thanks, jakamkon@…

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