Django:在inspectdb中使用多个数据库? [英] Django: using more than one database with inspectdb?
本文介绍了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
您不能同时检查两者。
这篇关于Django:在inspectdb中使用多个数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文