Ticket #1544: inspectdb.patch
File inspectdb.patch, 1.8 KB (added by , 19 years ago) |
---|
-
django/core/management.py
603 603 startapp.help_doc = "Creates a Django app directory structure for the given app name in the current directory." 604 604 startapp.args = "[appname]" 605 605 606 def inspectdb( db_name):606 def inspectdb(): 607 607 "Generator that introspects the tables in the given database name and returns a Django model, one line at a time." 608 608 from django.db import connection, get_introspection_module 609 609 from django.conf import settings … … 615 615 object_name = table_name.title().replace('_', '') 616 616 return object_name.endswith('s') and object_name[:-1] or object_name 617 617 618 settings.DATABASE_NAME = db_name619 618 cursor = connection.cursor() 620 619 yield "# This is an auto-generated Django model module." 621 620 yield "# You'll have to do the following manually to clean this up:" … … 705 704 yield ' db_table = %r' % table_name 706 705 yield '' 707 706 inspectdb.help_doc = "Introspects the database tables in the given database and outputs a Django model module." 708 inspectdb.args = " [dbname]"707 inspectdb.args = "" 709 708 710 709 class ModelErrorCollection: 711 710 def __init__(self, outfile=sys.stdout): … … 1071 1070 action_mapping[action]() 1072 1071 elif action == 'inspectdb': 1073 1072 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](): 1079 1074 print line 1080 1075 except NotImplementedError: 1081 1076 sys.stderr.write("Error: %r isn't supported for the currently selected database backend.\n" % action)