0

I am running a django project on a raspberry pi and want to move the database to an external hard drive that is connected. my settings looks like this:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': '/mnt/MOCStorage/database.db,
    }
}

When I run manage.py migrate, I get this error:

django.db.utils.OperationalError: unable to open database file

I have mounted the drive to /mnt/MOCStorage and used chmod to change the permissions of /mnt and /mnt/MOCStorage to 775.

How can I get this database to work here?

2
  • I don't know if it is true now, but back in the days sqlite was creating journal file in the same directory, where the database file is. That means the user who runs manage.py would require write permissions on the parent directory as well. Commented Nov 8, 2018 at 18:38
  • both directories should be writable. I tried chmod 777 on both directories and still am not getting anything to work. Commented Nov 8, 2018 at 18:54

1 Answer 1

1

Looks like you've missed the closing quotation:

'NAME': '/mnt/MOCStorage/database.db,

should read:

'NAME': '/mnt/MOCStorage/database.db',

However I would suspect this should throw a different error from the one you've mentioned, and this error may just be in your quote.

In which case perhaps try touch /mnt/MOCStorage/database.db as the webapp user to confirm write perms.

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.