OperationalError: unable to open database file
database, database-connection, flask, python, sqlite
Solution
Escape your string properly:
DATABASE = 'C:\\Users\\Brad\\Documents\\flaskr\\flaskr.db'
Problem
I'm running through the Flask tutorial for a simple blog/cms and I can't seem to open/create a database. I'm currently on Windows 7, when I go to view the app I get a sqlite3.OperationalError OperationalError: unable to open database file error on the webpage. I've tried googling the issue but I haven't been able to fix it. I assume it has to do with that I'm using Windows. Can anyone help? ``` DATABASE = 'C:\Users\Brad\Documents\flaskr\flaskr.db' def connect_db(): return sqlite3.connect(app.config['DATABASE']) def init_db(): with closing(connect_db()) as db: with app.open_resource('schema.sql') as f: db.cursor().executescript(f.read()) db.commit() ```