Skip to content
Advertisement

python sqlite3 OperationalError: attempt to write a readonly database

I am trying to run a Flask REST service on CentOS Apache2 using WSGI. The REST service requires a very small storage. So i decided to use SQLite with sqlite3 python package. The whole application worked perfectly well on my local system and on the CentOS server when ran using app.run(). But when i used WSGI to host the application on Apache, i am getting

JavaScript

I have checked the permissions of the file. The user and group of the file are set to apache (under which the server is running) using chown andchgrp. Also, the file has rwx permission. Still i am getting read-only database error. Following is what i get by running ls -al on the db file:

JavaScript

My Apache Configuration:

JavaScript

Advertisement

Answer

In addition to changing the database file permissions, you need also to change permissions for the directory that hosts the database file. You can try the following command:

JavaScript

You can also change the directory’s owner as follows:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement