Ưu đãi trong tuần: Nhập mã UD50 giảm 50k cho đơn từ 300k!
Trang chủ
Menu

SQLAlchemy ORM Query Fundamentals

Kiến thức nền tảng về truy vấn với SQLAlchemy ORM

Kiến thức nền tảng về truy vấn với SQLAlchemy ORM

Làm chủ sức mạnh của SQLAlchemy ORM thông qua kiến thức cơ bản về tương tác với cơ sở dữ liệu bằng Python.

4.3
(22 đánh giá)
206 học viên
Giảng viên
Very Academy
Phụ đề Việt chất lượng cao Phụ đề tiếng Anh Bán chạy Đánh giá cao
50.000đ 399.000đ -87%
✓ Xem giỏ hàng và thanh toán
Bao gồm phụ đề tiếng Việt, tiếng Anh
11.0 giờ video
90 bài giảng
Truy cập vĩnh viễn
Học trên mọi thiết bị
Cập nhật: 28/05/2026

Bạn sẽ học được gì

Thiết lập môi trường phát triển bao gồm Python, VSCode và môi trường ảo cho SQLAlchemy.
Học cách định nghĩa các bảng cơ sở dữ liệu dưới dạng model của SQLAlchemy ORM với quan hệ, ràng buộc và trình lắng nghe sự kiện.
Tạo và quản lý các bảng cơ sở dữ liệu bằng SQLAlchemy ORM và PostgreSQL.
Thực hiện thao tác chèn, cập nhật, xóa dữ liệu và quản lý giao dịch với SQLAlchemy ORM.
Truy xuất và thao tác hiệu quả các bản ghi cơ sở dữ liệu bằng các tiện ích truy vấn của SQLAlchemy.
Áp dụng các kỹ thuật lọc để tinh chỉnh truy vấn cơ sở dữ liệu với SQLAlchemy ORM.
Sử dụng các loại phép JOIN khác nhau trong SQL để kết hợp dữ liệu từ nhiều bảng.
Thực hiện tổng hợp, nhóm và lọc dữ liệu để phân tích các bản ghi cơ sở dữ liệu.

Yêu cầu

Không yêu cầu kinh nghiệm lập trình – mọi thứ đều được cung cấp đầy đủ.

Đối tượng phù hợp

Lập trình viên Python từ cơ bản đến trung cấp – Những người muốn tích hợp cơ sở dữ liệu vào ứng dụng của mình bằng SQLAlchemy ORM.
Chuyên viên phân tích và kỹ sư dữ liệu – Các chuyên gia cần tương tác với cơ sở dữ liệu SQL thông qua lập trình.
Nhà phát triển web – Đặc biệt là những người làm việc với Flask hoặc FastAPI và cần một ORM để quản lý thao tác cơ sở dữ liệu.
Kỹ sư phần mềm – Bất kỳ ai xây dựng ứng dụng yêu cầu truy vấn và quản lý cơ sở dữ liệu hiệu quả.
Sinh viên và người học ngành khoa học máy tính – Những cá nhân đang tìm hiểu về cơ sở dữ liệu quan hệ và khái niệm ORM.
Những người đam mê kỹ thuật – Bất kỳ ai tò mò về SQLAlchemy và các thao tác cơ sở dữ liệu dựa trên ORM.

Nội dung khóa học

9 phần • 90 bài giảng
1 Tổng quan khóa học
2 SQLAlchemy
1 Giới thiệu module
2 Windows: Cài đặt Python
3 MacOS: Cài đặt Python
4 Hướng dẫn nhanh: VS Code cho Windows
5 Hướng dẫn nhanh: VS Code cho MacOS
6 Hướng dẫn nhanh: Tạo môi trường ảo trên Windows
7 Hướng dẫn nhanh: Tạo môi trường ảo trên MacOS
1 Giới thiệu module
2 Sơ đồ quan hệ thực thể (ERD) của cơ sở dữ liệu
3 Bắt đầu một dự án SQLAlchemy mới
4 Declarative Base
5 Định nghĩa bảng cơ sở dữ liệu dưới dạng Model
6 Các kiểu trường phổ biến
7 Trường ngày tháng và thời gian
8 Trường bắt buộc, trường null và trường trống
9 Giá trị mặc định
10 Giá trị duy nhất
11 Tạo khóa chính
12 Tạo khóa ngoại
13 Quan hệ tự tham chiếu
14 Hành vi khi xóa (On-Delete)
15 Định nghĩa quan hệ Nhiều-Nhiều
16 Tạo quan hệ Một-Một
17 Giới thiệu về ràng buộc ở cấp độ cơ sở dữ liệu
18 Giới thiệu về trình lắng nghe sự kiện trong SQLAlchemy
19 Giới thiệu về trình lắng nghe sự kiện ở cấp độ cơ sở dữ liệu (Trigger)
20 Mã nguồn
1 Giới thiệu module
2 Thiết lập PostgreSQL với Docker
3 Tạo Engine
4 ORM Session
5 Tạo và xóa bảng trong cơ sở dữ liệu
6 Mã nguồn + Hướng dẫn cài đặt
1 Giới thiệu module
2 Chèn dữ liệu bằng add() và commit()
3 Chèn hàng loạt bằng add_all()
4 Chèn hàng loạt bằng bulk_insert_mappings
5 Chèn hàng loạt bằng bulk_save_objects
6 Cập nhật bản ghi đã tồn tại
7 Cơ chế theo dõi (ORM Tracking)
8 Chèn dữ liệu vào bảng có khóa ngoại
9 Sử dụng Flush trong SQLAlchemy
10 Chèn dữ liệu vào bảng Một-Một
11 Chèn dữ liệu vào bảng Nhiều-Nhiều
12 Xóa bản ghi
13 Xóa bản ghi có quan hệ
14 Xử lý và mã hóa các trường nhạy cảm
15 Mã nguồn + Hướng dẫn cài đặt
1 Giới thiệu module
2 Tạo dữ liệu mẫu (Seeding)
3 Sử dụng SELECT để truy xuất bản ghi
4 Chọn cột cụ thể với WHERE
5 Kiểm tra câu lệnh SQL thô
6 Sử dụng tiện ích first()
7 Sử dụng tiện ích count()
8 Sử dụng tiện ích limit()
9 Sử dụng tiện ích exists()
10 Sử dụng tiện ích order_by()
11 Sử dụng @classmethod trong Model
12 Mã nguồn + Hướng dẫn cài đặt
1 Giới thiệu module
2 Phương thức where() – Phương thức lọc tổng quát
3 Logic AND và OR trong lọc dữ liệu
4 Hàm like()
5 Các toán tử so sánh cơ bản
6 Hàm between
7 Hàm in_()
8 Tiện ích distinct
9 Truy vấn kết hợp (Composable Queries)
10 Mã nguồn + Hướng dẫn cài đặt
1 Giới thiệu module
2 Inner Join với khóa ngoại
3 Inner Join Một-Một
4 Inner Join Nhiều-Nhiều
5 Left Join với khóa ngoại
6 Left Join với quan hệ Một-Một
7 Left Join với quan hệ Nhiều-Nhiều
8 Full Outer Join
9 Full Outer Join (loại trừ)
10 Mã nguồn + Hướng dẫn cài đặt
1 Giới thiệu module
2 Hàm Count
3 Hàm Sum
4 Hàm Average
5 Nhóm kết quả bằng group_by()
6 Lọc kết quả đã nhóm bằng having()
7 Hàm Min và Max
8 Mã nguồn + Hướng dẫn cài đặt

Giới thiệu khóa học

Master the power of SQLAlchemy ORM with this in-depth course designed to teach you the fundamentals of database interaction using Python. Whether you're a developer, data professional, or aspiring backend engineer, this course will equip you with the skills to define, query, and manage databases efficiently.

Starting with setting up your development environment, you'll learn how to define database models, establish relationships, and enforce constraints using SQLAlchemy’s declarative ORM. You’ll then dive into generating tables, inserting and updating records, and executing complex queries with filtering, joins, and aggregations.

By the end of this course, you'll be able to integrate SQLAlchemy ORM into real-world projects, optimize data retrieval, and leverage the full power of Python for database management.

This course is perfect for Python developers, backend engineers, data analysts, and anyone looking to gain expertise in ORM-based database operations.


Learning Outcomes

By the end of this course, learners will be able to:

1. Introductions

  • Understand the course coverage, aims, and objectives.

  • Explain the purpose of SQLAlchemy ORM and its advantages in database management.

2. Preparing for Development

  • Set up a development environment for SQLAlchemy on both Windows and macOS.

  • Install Python and configure it for SQLAlchemy development.

  • Set up VSCode for SQLAlchemy development on Windows and macOS.

  • Create and manage virtual environments for dependency management.

3. Fundamentals - Defining Database Tables (Models)

  • Understand the structure of the database through an ERD.

  • Create a new SQLAlchemy project with a declarative base.

  • Define database tables using SQLAlchemy ORM models.

  • Identify and apply different field types, including DateTime fields.

  • Implement required, nullable, and default values in table columns.

  • Enforce uniqueness constraints and define primary and foreign keys.

  • Establish self-referencing relationships in tables.

  • Implement on-delete behaviors for foreign key constraints.

  • Define and manage many-to-many and one-to-one relationships.

  • Introduce database-level constraints and event listeners.

  • Utilize database-level event listeners (triggers) for automation.

  • Convert models to Python type hinting for improved readability and maintainability.

4. Fundamentals - Generating Tables from Models

  • Set up PostgreSQL using Docker.

  • Create a database engine using SQLAlchemy.

  • Establish and manage ORM sessions for interacting with the database.

  • Generate tables from ORM models.

  • Drop and recreate tables as needed.

5. Fundamentals - Inserting, Updating, and Deleting Data

  • Insert records using add() and commit().

  • Perform bulk inserts using add_all(), bulk_save_objects(), and bulk_insert_mappings().

  • Update existing records with SQLAlchemy ORM.

  • Track changes to ORM-managed objects.

  • Insert records into tables with foreign keys and relationships.

  • Use flush() to manage transactions effectively.

  • Implement record deletion, including handling relationships.

  • Secure sensitive fields through encryption techniques.

  • Set and manage server-side default values.

  • Use PostgreSQL and DataGrip to insert and update data efficiently.

6. Fundamentals - Querying the Database

  • Populate the database with seed data.

  • Retrieve records using SELECT.

  • Filter records using WHERE conditions.

  • Inspect raw SQL generated by SQLAlchemy ORM.

  • Utilize common query utilities:

    • first(), count(), limit(), exists(), and order_by().

  • Implement @classmethod to define reusable query logic in models.

7. Fundamentals - Filtering

  • Apply the where() filtering method.

  • Combine filters using AND and OR logic.

  • Use basic comparison operators for queries.

  • Implement filtering functions such as like(), in_(), and between().

  • Retrieve distinct records using distinct().

  • Construct composable queries for better query optimization.

8. Fundamentals - Joins

  • Perform inner joins for:

    • Foreign key relationships

    • One-to-one relationships

    • Many-to-many relationships

  • Perform left joins for:

    • Foreign key relationships

    • One-to-one relationships

    • Many-to-many relationships

  • Execute full outer joins and exclude specific results.

9. Fundamentals - Aggregation and Grouping

  • Perform aggregate calculations using:

    • count(), sum(), avg(), min(), and max().

  • Group results using group_by().

  • Filter grouped results using having().

Khóa học liên quan

Khám phá thêm các khoá học cùng chủ đề

Hiển thị tất cả khoá học Database
Hiển thị tất cả khoá học Orm
Hiển thị tất cả khoá học Python
Hiển thị tất cả khoá học Sqlalchemy
Zalo
Tôi có thể tư vấn khoá học cho bạn 😊