相关疑难解决方法(0)

不同的数据库在Django中进行测试?

DATABASES = {
#    'default': {
#        'ENGINE': 'postgresql_psycopg2',
#        ...
#    }

    # for unit tests
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'mydatabase'
    }
}
Run Code Online (Sandbox Code Playgroud)

我有两个数据库:一个我想用于单元测试,一个用于其他一切.是否可以在Django 1.2.4中配置它?

(我问的原因是因为使用postgresql我收到以下错误:

foo@bar:~/path/$ python manage.py test
Creating test database 'default'...
Got an error creating the test database: permission denied to create database

Type 'yes' if you would like to try deleting the test database 'test_baz', or 'no' to cancel: yes
Destroying old test database...
Got an error recreating the test database: database "test_baz" does …
Run Code Online (Sandbox Code Playgroud)

sqlite django postgresql unit-testing

53
推荐指数
6
解决办法
3万
查看次数

标签 统计

django ×1

postgresql ×1

sqlite ×1

unit-testing ×1