🚀 Building a Robust PostgreSQL and SQLAlchemy Setup 🎥
In this video, we embark on an exciting journey to set up a PostgreSQL database with SQLAlchemy and Alembic for a modern and scalable project. From Docker setup to implementing advanced features like UUIDs, JSONB, and data migrations, we cover everything you need to create a high-performing database backend. Whether you're a beginner or looking to enhance your database skills, this video has you covered! 💻
Codes:
https://github.com/bakrianoo/mini-rag/tree/tut-013
Chapters:
00:00 The dream
00:19 Why Postgres?
03:25 create a GitHub release
07:30 Setup postgres docker?
15:51 DBeaver
18:37 How does SQLAlchemy work?
21:09 Setup first SQLAlchemy database schemes
24:00 update system configurations
29:00 Async Postgres connection
34:10 database directory structure
35:20 SQLAlchemy Declarative Base
38:35 Projects table scheme
51:50 Why do we need a UUID?
7
4:52 Table auto timestamp
51:55 Assets table
54:40 JSON Vs. JSONB
57:40 Foreign Keys
01:01:08 Table Indexes
01:04:24 Chunks table
01:09:40 setup schemes __init__
01:10:40 Introduction to Alembic and Data Migration
01:14:40 Setup Alembic project
01:17:35 Alembic configurations
01:22:30 Alembic revisions
01:28:40 Update models importing
01:33:00 Update primary keys definitions
01:36:00 Update project model
01:40:00 Commit a new record
01:46:40 SQLAlchemy Pagination
01:55:00 Update Datachunk model
01:58:00 Update Asset Model
02:01:50 Fixing | imports
02:03:15 Fixing | async/await
02:04:20 Fixing | Back populate Relation
02:07:39 Heeeey
02:09:07 Fixing | asset primary key name
02:11:18 Update RAG Prompts for better answers
02:16:30 Conclusion