|
所在平台: Udemy |
课程主页: https://www.udemy.com/course/sqlalchemy-orm-fundamentals/
课程评论:没有评论
**课程名称:SQLAlchemy ORM 查询基础** **课程概述:** 本课程旨在帮助学习者掌握 SQLAlchemy ORM 的强大功能,学习使用 Python 进行数据库交互的基础知识。无论您是开发者、数据专业人士还是后端工程师,本课程都将为您提供高效定义、查询和管理数据库的技能。 **核心内容:** * **环境准备:** 学习在 Windows 和 macOS 上设置 SQLAlchemy 开发环境,安装 Python,配置 VSCode,并管理虚拟环境。 * **数据库模型定义:** 理解 ERD 结构,使用 SQLAlchemy 的声明式 ORM 定义数据库表(模型),包括各种字段类型、约束(唯一性、主键、外键)、关系(一对一、多对多、自引用)以及数据库级事件监听器。 * **表生成与管理:** 使用 Docker 设置 PostgreSQL,创建 SQLAlchemy 引擎,管理 ORM 会话,并从 ORM 模型生成数据库表。 * **数据操作:** 学习插入、更新和删除记录,包括批量操作、事务管理、外键关联数据处理以及敏感字段的加密。 * **数据库查询:** 掌握基础的 SELECT、WHERE 查询,查看 SQLAlchemy 生成的 SQL 语句,并使用 `first()`, `count()`, `limit()`, `exists()`, `order_by()` 等常用查询实用程序。 * **过滤与组合:** 学习使用 `where()` 方法,组合 AND/OR 条件,应用 `like()`, `in_()`, `between()` 等过滤函数,以及提取唯一记录(`distinct()`)。 * ** JOIN 操作:** 深入学习不同类型的 JOIN 操作(内连接、左连接、全外连接)及其在各种关系下的应用。 * **聚合与分组:** 学习使用 `count()`, `sum()`, `avg()`, `min()`, `max()` 等函数进行聚合计算,并使用 `group_by()` 和 `having()` 进行分组和过滤。 **学习目标:** 学完本课程后,学习者将能够: * 理解 SQLAlchemy ORM 的目的和优势。 * 熟练配置开发环境。 * 使用 SQLAlchemy ORM 定义、生成和管理数据库表。 * 高效地插入、更新和删除数据库记录。 * 进行复杂的数据库查询,包括过滤、JOIN 和数据聚合。 * 将 SQLAlchemy ORM 集成到实际项目中,优化数据检索。 **目标受众:** Python 开发者、后端工程师、数据分析师以及任何希望掌握 ORM 数据库操作的开发者。
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 OutcomesBy the end of this course, learners will be able to:1. IntroductionsUnderstand the course coverage, aims, and objectives.Explain the purpose of SQLAlchemy ORM and its advantages in database management.2. Preparing for DevelopmentSet 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 ModelsSet 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 DataInsert 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 DatabasePopulate 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 - FilteringApply 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 - JoinsPerform inner joins for:Foreign key relationshipsOne-to-one relationshipsMany-to-many relationshipsPerform left joins for:Foreign key relationshipsOne-to-one relationshipsMany-to-many relationshipsExecute full outer joins and exclude specific results.9. Fundamentals - Aggregation and GroupingPerform aggregate calculations using:count(), sum(), avg(), min(), and max().Group results using group_by().Filter grouped results using having().