3

django sets up a database in memory for testing if the database engine selected is sqlite3. However, I need the database to be on the filesystem. How can I change the settings to make this possible?

1
  • Why do you need the db on the filesystem? I wouldn't recommend using SQLite for anything serious. Commented Mar 14, 2015 at 1:03

1 Answer 1

5

According to the documentation:

By default the test databases get their names by prepending test_ to the value of the NAME settings for the databases defined in DATABASES. When using the SQLite database engine the tests will by default use an in-memory database (i.e., the database will be created in memory, bypassing the filesystem entirely!). If you want to use a different database name, specify NAME in the TEST dictionary for any given database in DATABASES.

Specify the NAME key in the TEST dictionary:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        ...
        'TEST': {
            'NAME': '/path/to/the/db/file'
        }
    }
}

Note that for Django 1.6 and below, you should set TEST_NAME instead:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', 
        ...
        'TEST_NAME': '/path/to/the/db/file'
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.