OperationalError: unable to open database file


Question

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()
1
2
9/29/2015 9:23:10 AM

Accepted Answer

Escape your string properly:

DATABASE = 'C:\\Users\\Brad\\Documents\\flaskr\\flaskr.db'
5
6/3/2012 9:29:41 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon