I have a Flask app where I call sqlite3.connect('database.db')
. This causes the error: sqlite3.OperationalError: unable to open database file
. This seems to work fine when testing on Windows but not on Debian.
My project is organized as so:
flaskapp.wsgi
flask_app
__init__.py
init_db.py
database.db
init_db.py
creates the database with a table and an entry for that table, running that works just fine. __init__.py
has the flask app itself with the following method inside it:
def get_db_connection():
conn = sqlite3.connect('database.db')
conn.row_factory = sqlite3.Row
return conn
The stacktrace ends at the first line of this method with the error previously mentioned. For more context the app works when I test it out with the development server on Windows 10. But not on my webserver which is running Debian and Apache2.
I expect it to simply connect and do all the database stuff I want to do. I suspect it has something to do with Apache2 having some default behavior I didn't expect in relation to Flask. It doesn't appear to be an issue with file permissions, I tried everything that was recommended in this answer: https://stackoverflow.com/a/4637055/21932305 but I still have the error.