tags:

views:

55

answers:

1

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?

A: 

If you don't know where the 500 error is coming from, set DEBUG=True in your settings, and look at the debug stack trace page that is produced. It will show you where the exception is being raised.

Ned Batchelder
sorry Ned I edited the question to be more clear
Fanooos