In this video I'll show you how to use databases with Flask using SQLAlchemy!
Using databases with flask is a little harder than with other web frameworks, but it doesn't have to be too bad if you use SQLAlchemy. I'll show you how in this video by setting up a SQLite database and creating a table, and then adding a form to the site that allows us to add data to the database.
After we learn how to do this with SQLite, we'll learn about MySQL and Postgres.
Timecodes
0:00 - Introduction
1:13 - Pip Install Flask-SQLAlchemy
1:56 - Import SQLalchemy To Our Flask App
2:55 - Set SQLAlchemy Database URI For SQLITE
4:20 - Initialize The Database
4:50 - Create Our Database Model
9:39 - Import Model From The Terminal
10:38 - Create UserForm
11:25 - Create Route And Add_User Function
12:20 - Create Add_User.html Page
13:24 - Add Link To Add_User.html on Navbar
14:22 - Set Form to UserForm in Add_User Function
15:00 - Validate Form On Submit
16:54 - Save Data To Database On Submit
18:50 - Query Database And Output Users To Webpage
21:37 - Style Form With Bootstrap
22:37 - Add Table For User Output
24:46 - Conclusion
Watch video How to Use Databases With SQLAlchemy - Flask Fridays #8 online without registration, duration 25 minute 36 second in high hd quality. This video was added by user Codemy.com 05 March 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 94 thousand once and liked it 1 thousand people.