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
From the course: Flask Essential Training
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
-
-
-
-
-
-
-
-
(Locked)
Setting up SQLAlchemy5m 35s
-
(Locked)
Model creation1m 55s
-
(Locked)
Conceptual overview of create and read2m 29s
-
(Locked)
Create and read operations6m 26s
-
(Locked)
Conceptual overview of update and delete1m 44s
-
(Locked)
Update and delete operations3m 24s
-
(Locked)
Project step 7: Integrating the SQLite database with Flask2m 46s
-
(Locked)
Project step 8: Implementing create and read operations3m 25s
-
(Locked)
-
-
-