[英]Django Not Recognizing Multiple Databases
I'm trying to use multiple databases with my Django project but it is only recognizing the default one. 我正在尝试在我的Django项目中使用多个数据库,但是它只能识别默认数据库。 In my settings.py file I have the following set:
在我的settings.py文件中,我进行了以下设置:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": "primary",
"USER": "admin",
"PASSWORD": "password",
"HOST": "",
"PORT": "",
},
"deals": {
"ENGINE": 'django_mongodb_engine',
"NAME": "database",
"HOST": "HOSTNAME",
"PORT": "27017",
"USER": "",
"PASSWORD": "",
"SUPPORTS_TRANSACTIONS": False,
},
}
But when I try to run 但是当我尝试跑步时
python manage.py syncdb --database=deals
or 要么
python manage.py inspectdb --database=deals
I am getting the following error: 我收到以下错误:
django.db.utils.ConnectionDoesNotExist: The connection deals doesn't exist
When I try to debug in /lib/python2.7/site-packages/django/db/utils.py I am seeing that only the default database is being recognized. 当我尝试在/lib/python2.7/site-packages/django/db/utils.py中进行调试时,我看到只有默认数据库可以识别。 I get the same error when I try to create a second local database.
尝试创建第二个本地数据库时,出现相同的错误。
EDIT I've updated my settings.py file according to the comments but still have the same issue. 编辑我已经根据评论更新了settings.py文件,但仍然存在相同的问题。
Maybe the indentation? 也许缩进? I checked it with my code, it looks ok.
我用我的代码检查了它,看起来还可以。 Or it does not support multiple Databases with MongoDB.
或它不支持MongoDB使用多个数据库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.