Ticket #19775: default_database_entry_required_clarification.diff

File default_database_entry_required_clarification.diff, 1.9 KB (added by Warren Smith, 11 years ago)
  • docs/topics/db/multi-db.txt

    diff --git a/docs/topics/db/multi-db.txt b/docs/topics/db/multi-db.txt
    index 8a02305..380d403 100644
    a b documentation.  
    2020
    2121Databases can have any alias you choose. However, the alias
    2222``default`` has special significance. Django uses the database with
    23 the alias of ``default`` when no other database has been selected. If
    24 you don't have a ``default`` database, you need to be careful to
    25 always specify the database that you want to use.
     23the alias of ``default`` when no other database has been selected.
    2624
    2725The following is an example ``settings.py`` snippet defining two
    2826databases -- a default PostgreSQL database and a MySQL database called
    databases -- a default PostgreSQL database and a MySQL database called  
    4543        }
    4644    }
    4745
     46If the concept of a ``default`` database doesn't make sense in the context
     47of your project, you need to be careful to always specify the database
     48that you want to use. Django requires that a ``default`` database entry
     49be defined, but the parameters dictionary can be empty if it will not
     50be used.
     51
     52The following is an example ``settings.py`` snippet defining two non-default
     53databases, with the default entry intentionally left empty.
     54
     55.. code-block:: python
     56
     57    DATABASES = {
     58        'default': {},
     59        'users': {
     60            'NAME': 'user_data',
     61            'ENGINE': 'django.db.backends.mysql',
     62            'USER': 'mysql_user',
     63            'PASSWORD': 'superS3cret'
     64        },
     65        'customers': {
     66            'NAME': 'customer_data',
     67            'ENGINE': 'django.db.backends.mysql',
     68            'USER': 'mysql_cust',
     69            'PASSWORD': 'veryPriv@ate'
     70        }
     71    }
     72
    4873If you attempt to access a database that you haven't defined in your
    4974:setting:`DATABASES` setting, Django will raise a
    5075``django.db.utils.ConnectionDoesNotExist`` exception.
Back to Top