Code

Opened 8 years ago

Closed 8 years ago

Last modified 8 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
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: UI/UX:

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

Attachments (0)

Change History (1)

comment:1 Changed 8 years ago by adrian

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

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

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.