Python Django具有多个数据库

Python Django具有多个数据库,python,django,Python,Django,我有一个Django应用程序,它有两个配置的数据库,第一个是\u DB,第二个是\u DB 配置如下所示 DATABASES = { 'default': { 'ENGINE' : 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME' : 'emonitor',

我有一个Django应用程序,它有两个配置的数据库,第一个是\u DB,第二个是\u DB

配置如下所示

DATABASES = {
    'default': {
        'ENGINE'  : 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME'    : 'emonitor',                      # Or path to database file if using sqlite3.
        'USER'    : 'emonitor',                      # Not used with sqlite3.
        'PASSWORD': 'emonitor',                  # Not used with sqlite3.
        'HOST'    : '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT'    : '',                      # Set to empty string for default. Not used with sqlite3.
    },
    'nagios': {
        'ENGINE'  : 'django.db.backends.mysql',
        'NAME'    : 'nagios',
        'USER'    : 'emonitor',
        'PASSWORD': 'emonitor',
        'HOST'    : 'nagios.edc', 
        'PORT'    : '',
    },
}
nagios数据库是只读的,在路由器模块中配置

nagios数据库位于远程计算机上

我的应用程序从nagios数据库获取数据并将其插入本地数据库

如果nagios机器关闭,或者nagios机器上的mysql关闭,django服务器将启动以下错误

enter code here_mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host 'nagios.edc' (1)")
而且应用程序不工作

据我所知,Django服务器试图连接到所有配置的数据库

但是我想让我的应用程序工作,即使第二个数据库无法访问


如何执行此操作?

如果您不知道500错误来自何处,请在设置中设置DEBUG=True,然后查看生成的调试堆栈跟踪页面。它将显示引发异常的位置