diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-08-02 17:08:24 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-08-02 17:08:24 +0000 |
| commit | d9401b78f11b47c5daa95a4fa60925b3fed50203 (patch) | |
| tree | a12b4dd9c2d791b0cae428d70bb5fd012a64c753 /django/bin/django-admin.py | |
| parent | 1510ca1a80f811d6e681a880d7e49d413ce8afb4 (diff) | |
Added first stab at 'django-admin.py inspectdb', which takes a database name and introspects the tables, outputting a Django model. Works in PostgreSQL and MySQL. It's missing some niceties at the moment, such as detection of primary-keys and relationships, but it works. Refs #90.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@384 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/bin/django-admin.py')
| -rwxr-xr-x | django/bin/django-admin.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/django/bin/django-admin.py b/django/bin/django-admin.py index 9acb5cc2cf..8c4370f427 100755 --- a/django/bin/django-admin.py +++ b/django/bin/django-admin.py @@ -7,6 +7,7 @@ ACTION_MAPPING = { 'adminindex': management.get_admin_index, 'createsuperuser': management.createsuperuser, # 'dbcheck': management.database_check, + 'inspectdb': management.inspectdb, 'runserver': management.runserver, 'sql': management.get_sql_create, 'sqlall': management.get_sql_all, @@ -66,6 +67,17 @@ def main(): print_error("Your action, %r, was invalid." % action, sys.argv[0]) if action in ('createsuperuser', 'init'): ACTION_MAPPING[action]() + elif action == 'inspectdb': + try: + param = args[1] + except IndexError: + parser.print_usage_and_exit() + try: + for line in ACTION_MAPPING[action](param): + print line + except NotImplementedError: + sys.stderr.write("Error: %r isn't supported for the currently selected database backend." % action) + sys.exit(1) elif action in ('startapp', 'startproject'): try: name = args[1] |
