Ticket #1544: inspectdb.patch

File inspectdb.patch, 1.8 KB (added by pb@…, 19 years ago)
  • django/core/management.py

     
    603603startapp.help_doc = "Creates a Django app directory structure for the given app name in the current directory."
    604604startapp.args = "[appname]"
    605605
    606 def inspectdb(db_name):
     606def inspectdb():
    607607    "Generator that introspects the tables in the given database name and returns a Django model, one line at a time."
    608608    from django.db import connection, get_introspection_module
    609609    from django.conf import settings
     
    615615        object_name = table_name.title().replace('_', '')
    616616        return object_name.endswith('s') and object_name[:-1] or object_name
    617617
    618     settings.DATABASE_NAME = db_name
    619618    cursor = connection.cursor()
    620619    yield "# This is an auto-generated Django model module."
    621620    yield "# You'll have to do the following manually to clean this up:"
     
    705704        yield '        db_table = %r' % table_name
    706705        yield ''
    707706inspectdb.help_doc = "Introspects the database tables in the given database and outputs a Django model module."
    708 inspectdb.args = "[dbname]"
     707inspectdb.args = ""
    709708
    710709class ModelErrorCollection:
    711710    def __init__(self, outfile=sys.stdout):
     
    10711070        action_mapping[action]()
    10721071    elif action == 'inspectdb':
    10731072        try:
    1074             param = args[1]
    1075         except IndexError:
    1076             parser.print_usage_and_exit()
    1077         try:
    1078             for line in action_mapping[action](param):
     1073            for line in action_mapping[action]():
    10791074                print line
    10801075        except NotImplementedError:
    10811076            sys.stderr.write("Error: %r isn't supported for the currently selected database backend.\n" % action)
Back to Top