Flask OperationalError: unable to open database file using sqlite3 Flask OperationalError: unable to open database file using sqlite3 sqlite sqlite

Flask OperationalError: unable to open database file using sqlite3


I think that the problem is the ~ character (valid in shell but not in Python), so you will probably need to write the full absolute path. I am not using Flask but I suggest to set up PROJECT_ROOT constant in your settings and then use relative paths:

import osPROJECT_ROOT = os.path.dirname(os.path.realpath(__file__))DATABASE = os.path.join(PROJECT_ROOT, 'tmp', 'test.db')


This Worked for me :

When you define database in the beginning, don't just say app.database = 'example.db', instead, you have to specify the home directory path with double slashes:
"ex : //var//www//foldername//example.db" if you're using linux and restart the server again.