Python guides
Every published Python guide, newest first, with practical examples you can copy into your own project.
3,965 guides across 14 topics
Topics
Popular Python guides
Most readLatest Python guides
Page 29 of 179Python SQLAlchemy Primary Key, Foreign Key, and Relationships
python sqlalchemy primary key foreign key and relationships: Define primary keys, foreign keys, and relationship() mappings in SQLAlchemy, covering one-to-many, many-t...
Python SQLAlchemy Declarative Models: Tables and Columns
Learn how to map Python classes to database tables with SQLAlchemy declarative models, including column types, constraints, indexes, and relationships.
SQLAlchemy Engine, Connection, Session, and Sessionmaker Explained
Understand the distinct roles of SQLAlchemy's Engine, Connection, Session, and Sessionmaker, including when to use each, common pitfalls, and a web application session pattern.
python pydantic v1 vs v2: Key Differences and Migration
Compare python pydantic v1 vs v2: API changes, validation behavior, performance, and a practical migration path for existing projects.
Handling Python Pydantic Validation Errors
Learn how to catch, inspect, and customize Pydantic validation errors in Python, including error structure, manual raising, and FastAPI request handling.
Python Pydantic Dataclass vs BaseModel: Choosing the Right Approach
Compare Pydantic's dataclass and BaseModel for validation, serialization, and integration. Learn which approach fits your codebase and when to choose each.
Using Computed Fields with Generic Models in Pydantic
Learn how to combine Pydantic v2's computed_field with generic models: type parameter handling, serialization behavior, inheritance, custom serializers, and safe patterns.
Python Pydantic ConfigDict Extra Fields and Strict Mode
See how Pydantic ConfigDict's extra and strict settings control unknown fields and type coercion in Python models, with examples for API validation.
Python Pydantic Datetime and Custom Type Validation
Learn how to validate datetime fields in Pydantic v2: parse Unix timestamps, require timezone-aware values, and build reusable custom types.
Python Pydantic Nested Models, Lists, and Enums
Learn how to define and validate nested models, lists of models, and enum fields in Pydantic with clear examples, including optional values and common pitfalls.