开发者

Is it possible to use Django's testing framework without having CREATE DATABASE rights?

开发者 https://www.devze.com 2022-12-30 22:15 出处:网络
Since I don\'t have a hundred bazillion dollars, my Django app lives on a shared host, where all kinds of crazy rules are in effect. Fortunately, they gave me shell access, which has allowed me to kic

Since I don't have a hundred bazillion dollars, my Django app lives on a shared host, where all kinds of crazy rules are in effect. Fortunately, they gave me shell access, which has allowed me to kick butts and take names. However I can't do anything about not having CREATE DATABASE rights.

I'm using postgresql and have a killer test suite, but am unable to run it due to the code not being able to create a new database. However I am able to create said database beforehand via cPanel and use it with Django. I just don't have CREATE DATABASE rights.

Is there a way I can still run my test suite开发者_如何学JAVA?


You could maybe workaround this using sqlite3 engine to create a SQLite database. You can even create it in memory and drastically improve tests runtime.

To set it up just edit your database settings like this:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': ':memory:',
        ... # other settings (HOST, USER etc.)
    },
}
0

精彩评论

暂无评论...
验证码 换一张
取 消