2
因此,在我的settings.py中,我指定了两个数据库连接(请参阅下文)。Django测试 - 我只想要创建一个我的数据库 - 如何指定
但是当我运行测试时,我只想让Django创建'默认'数据库。
有没有办法做到这一点?我尝试添加TEST_CREATE:False选项,但我想这仅仅是出于某种原因对于Oracle?
我的settings.py片段:
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
}
}
也许看sys.argv中[1]设置中,看看你在测试模式下,并设置相应的数据库。 – mtnpaul