From the course: Flask Essential Training

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Setting up SQLAlchemy

Setting up SQLAlchemy

- [Instructor] SQLAlchemy is a powerful tool that lets us interact with the database in a Pythonic way. What do I mean by a Pythonic way? Well, we use Python code to perform database operations such as creating tables, inserting records, querying data, and we don't have to write raw SQL queries for it. There are a few steps involved in setting up a SQLAlchemy. First we install FLASK-SQLAlchemy. We add it to our FLASK app. We configure database URI, then initialize SQLAlchemy, then set FLASK app environment variable, and finally create the database. It's less work than it looks like. So let's walk through an example. To configure a database using SQLAlchemy within a FLASK app, you typically first install it using PIP install, but we have it installed as part of our requirements txt, so there's no need to install it right now. Just make sure it's listed in the requirements, which it is. We are working inside six dash one database setup directory in the starter folder. Let's open app.py…

Contents