Django Testing - I only want one of my databases created - how to specify
django, django-settings, django-testing
Solution
Well, here's one way to do it. I added this to settings.py after setting up my normal databases.
if 'test' in sys.argv:
DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3',}}
Problem
So in my settings.py I specified two database connections (see below). But when I run tests I only want Django to create the 'default' database. Is there any way to do this? I tried adding the TEST_CREATE: False option but I guess that's only for Oracle for some reason? My settings.py snippet: ``` DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'App1', # Or path to database file if using sqlite3. 'USER': 'webaccess', # Not used with sqlite3. 'PASSWORD': '***', # 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. }, 'default_root': { 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'App1', # Or path to database file if using sqlite3. 'USER': 'django', # Not used with sqlite3. 'PASSWORD': '****', # 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. 'TEST_CREATE': False #Don't create when testing } } ```