首先,我是在这里提问的新手,所以如果我做得不完美,请耐心等待:) 这是...
我正在设置一个处理统计信息的 Django2.0 API。它显然有自己的“默认”数据库来写东西,但我将需要其他几个只读的数据库。这就是现在的设置。
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'dev_gpws',
'USER': 'dev_gpws_user',
'PASSWORD': 'gpws_pwd',
'HOST': 'localhost',
'PORT': '5432',
},
'other_db': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'other_db_name',
'USER': 'other_db_user',
'PASSWORD': 'other_db_pwd',
'HOST': 'other_db_host',
'PORT': '5432',
},
}
Run Code Online (Sandbox Code Playgroud)
fabric 将项目部署到 staging 时,部分例程为./manage.py test,导致如下错误:
(gpws) dev_gpws@af968cdb7653:~/gpws/project$ ./manage.py test
Creating test database for alias 'default'...
Creating test database for alias 'other_db'...
Got an error creating the test database: ERREUR: permission denied to create database
Run Code Online (Sandbox Code Playgroud)
考虑到other_db_user是只读用户,这是完全有意义的,所以我想禁用 django 对此数据库的测试。有没有干净的方法来做到这一点?此外,此统计应用程序稍后将与相当多的数据库链接,因此我宁愿使用易于扩展的解决方案。 …