Django:在inspectdb中使用多个数据库?

问题描述:

我的设置文件的数据库部分如下所示:

My settings file's database section looks like this:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'C:/Users/Desktop/test.db'
    },
    'blah':{
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'C:/Users/Desktop/test2.db'
    }
}

当我运行命令 python manage.py inspectdb> models.py ,我只为默认数据库生成模型,而没有第二个模型。我如何才能生成两个模型?

When I run the command python manage.py inspectdb > models.py, I only get the model generated for the default database, but not the second one. How could I get both models generated?

文档


-数据库DATABASE

指定要自检的数据库。默认值为默认

Specifies the database to introspect. Defaults to default.

因此,您可以使用以下命令检查第二个数据库: / p>

So you can inspect your second database with:

python manage.py inspectdb --database blah

您不能同时检查两者。