app/django/core/management/commands/dbshell.py
changeset 323 ff1a9aa48cfd
parent 54 03e267d67478
equal deleted inserted replaced
322:6641e941ef1e 323:ff1a9aa48cfd
     1 from django.core.management.base import NoArgsCommand
     1 from django.core.management.base import NoArgsCommand, CommandError
     2 
     2 
     3 class Command(NoArgsCommand):
     3 class Command(NoArgsCommand):
     4     help = "Runs the command-line client for the current DATABASE_ENGINE."
     4     help = "Runs the command-line client for the current DATABASE_ENGINE."
     5 
     5 
     6     requires_model_validation = False
     6     requires_model_validation = False
     7 
     7 
     8     def handle_noargs(self, **options):
     8     def handle_noargs(self, **options):
     9         from django.db import runshell
     9         from django.db import connection
    10         runshell()
    10         try:
       
    11             connection.client.runshell()
       
    12         except OSError:
       
    13             # Note that we're assuming OSError means that the client program
       
    14             # isn't installed. There's a possibility OSError would be raised
       
    15             # for some other reason, in which case this error message would be
       
    16             # inaccurate. Still, this message catches the common case.
       
    17             raise CommandError('You appear not to have the %r program installed or on your path.' % \
       
    18                 connection.client.executable_name)