I have a Django application with two configured databases first_DB and second_DB
The configurations seems as following
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' : '',
},
}
The nagios database is readonly and this is configured in the routers module.
The nagios database is on a remote machine
my application gets data from nagios DB and inserts it into my local DB
If the nagios machine is down, or mysql on nagios machine is turned off, the django server starts with the following error
enter code here_mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host 'nagios.edc' (1)")
and the application does not work
What I understand is that Django server tries to connect to all the configured databases
but I want to get my application working even if the second database is unreachable
How can I do that?