0

I was starting to learn Flask-SQLAlchemy and this was my first project, I was trying to make a blog Application. And I just can't connect this database!

I've tried several ways of connecting using several ways such as wrapping the connections in try: and except: code blocks. and alot of other things but none of theme seems to work.

app = Flask(__name__)

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:\\\\E:\Blog\database.db'

db = SQLAlchemy(app)

I've this code to connect the database right now, this throws the following error: sqlalchemy.exc.ArgumentError: Could not parse rfc1738 URL from string 'E:\Blog\database.db'

As far as I can understand the situation I think it is the error of the file path, but no file path seem to work! I've tried using: sqlite:////mnt/e/Blog/database.db From another stackOverflow instance but looks like it was for UNIX. Please help!

2
  • I think you have an extra backspace before E:. Please remove the extra backslash so that is now 'sqlite:\\\...' instead of 'sqlite:\\\\.... Commented Apr 3, 2019 at 14:50
  • Sorry to say, but this didn't work. I was following docs for the format of the URI. but i lost them, just doesn't seem to find it anymore Commented Apr 3, 2019 at 18:03

1 Answer 1

1

You should put forward slashes at the beginning not backward

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///C:\\absolute\\path\\to\\foo.db'
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.