Python Backend #3: Connect Flask to a Database (SQLite CRUD Tutorial)
1.9K views on YouTube
π¦ Persist your data with SQLite!
In this video, we connect our Flask API to a real database using SQLite. Youβll learn how to create a products.db file, write SQL queries with Python, and replace your in-memory lists with persistent storage β perfect for real-world apps!
Previous Project files: https://github.com/NDCSwift/Swift-Projects/raw/refs/heads/main/Python-Projects/PythonBackEnd2_app.py.zip
π§ What Youβll Learn:
β
How to create and connect to a SQLite database
β
How to create tables using raw SQL
β
How to replace in-memory storage with real persistence
β
How to use Postman to test your API
π Tools Used:
Python 3
Flask
SQLite (built-in)
VS Code
DB Browser for SQLite https://sqlitebrowser.org/
Postman or curlπ₯ Download My Project Files
π Get the source code here:
π https://ndcswift.github.io/Swift-Projects/
β±οΈ Timestamps:
00:00 β Intro
01:12 β SQLite
01:31 β Creating a database connection
02:51 β Defining our product table
06:33 β Rewriting the POST route
08:55 β Rewriting the GET route
10:14 β Testing everything with Postman
15:00 β Moving your Data base
16:02 β SQLite browser
16:28 β Updating database connection (After moving file)
18:05 β Recap & whatβs next