简体   繁体   中英

Django Test Wants Access To Master Database MS SQL Server

I've got an application that is running Django 2 that connects to a Microsoft SQL Server backend.

We're in a big environment where things are pretty tightly controlled - a user account has access to the database that houses all the tables for my django application.

It does not have access to the master database on the SQL Server and any request for an account that does have that level of access would likely be denied. It can create tables in the existing database, but cannot create entirely new databases.

When I run the tests for the application I get the error:

Got an error creating the test database: ('42000', "[42000] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]CREATE DATABASE permission denied in database 'master'. (262) (SQLExecDirectW)")

So what is the best course of action for this? Is there a way to manually create the 'test database' and have Django use that for testing purposes so it isn't trying to create a new database when running tests?

We ended up having to specify a different database (a local SQLite instance) for testing specifically because the MS-SQL Server instance was locked down on a per user basis and the user rights for django were not going to be allowed to change.

It required additional setup and changing of process' in order to accommodate using local SQLite, but hey, testing works!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM