#Programming Language

189 posts

SQLAlchemy 2.0 #7 Alembic and Production Setup: Migrations, Async, Team Rules
5 min read

SQLAlchemy 2.0 #7 Alembic and Production Setup: Migrations, Async, Team Rules

The series finale on operational topics: why create_all cannot handle schema changes and Alembic takes over, what autogenerate detects and what it misses, the review rules for migration files, going async with create_async_engine and AsyncSession and the lazy-loading restriction that comes with it, laying out models, sessions, and settings in a project, and the team rules worth enforcing.

Rust Basics #7 Collections and Iterators: Vec, String, HashMap, and Chains Instead of for
4 min read

Rust Basics #7 Collections and Iterators: Vec, String, HashMap, and Chains Instead of for

The three collections that make up the body of practical code. Vec and why get is used instead of indexing, why String cannot be indexed at all (UTF-8 and the difference between bytes and characters), HashMap and the entry API, and the iterator style — map, filter, collect chains with lazy evaluation — that replaces for loops.

SQLAlchemy 2.0 #6 Advanced Queries: Joins, Aggregation, Subqueries, Bulk Operations
5 min read

SQLAlchemy 2.0 #6 Advanced Queries: Joins, Aggregation, Subqueries, Bulk Operations

Building real-world queries on select() alone: the difference between scalars and execute return shapes, combining conditions with or_, joins and explicit ON clauses, reading group_by aggregates through labels, subqueries and EXISTS, LIMIT-OFFSET pagination and its limits versus keyset pagination, and bulk INSERT and UPDATE that bypass the ORM unit of work.

Rust Basics #6 Error Handling: Result, the ? Operator, and the Boundary Between panic and unwrap
5 min read

Rust Basics #6 Error Handling: Result, the ? Operator, and the Boundary Between panic and unwrap

Error handling in a language with no exceptions. Result, which puts the possibility of failure into the return type; the ? operator that collapses nested match blocks into one character and propagates errors; the practical form where main returns a Result; and the judgment calls for when unwrap, expect, and panic are acceptable and when they are not.

SQLAlchemy 2.0 #5 Relationships: One-to-Many, Many-to-Many, and the N+1 Problem
5 min read

SQLAlchemy 2.0 #5 Relationships: One-to-Many, Many-to-Many, and the N+1 Problem

The ORM at its best and its most dangerous — relationship(): how foreign keys and relationship() divide the work, declaring bidirectional one-to-many with back_populates, many-to-many through a secondary table, cascade and delete-orphan for parent-child lifecycles, spotting the N+1 problem that lazy loading creates by reading the echo log, and choosing between selectinload and joinedload to fix it.

Rust Basics #5 Structs and Enums: match, Option, and Designing Without null
4 min read

Rust Basics #5 Structs and Enums: match, Option, and Designing Without null

The two axes of structuring data: structs and enums. Attaching methods with impl blocks, the expressiveness of Rust enums whose variants carry different data, match with compiler-enforced exhaustiveness, and Option — the type that expresses "there may be no value" instead of null. The tools that form the skeleton of Rust code.

SQLAlchemy 2.0 #4 The Session: Change Tracking, flush vs commit, and the Four Object States
5 min read

SQLAlchemy 2.0 #4 The Session: Change Tracking, flush vs commit, and the Four Object States

The heart of the ORM, the Session: how it batches changes as a unit of work and emits them as SQL, the difference between flush and commit, the four object states — transient, pending, persistent, detached — the identity map that returns the same object for the same row, why attribute access after commit triggers a new query, and the one-session-per-request scoping rule for web applications.

Rust Basics #4 References and Borrowing: & and &mut, Solving Borrow-Rule Compile Errors
5 min read

Rust Basics #4 References and Borrowing: & and &mut, Solving Borrow-Rule Compile Errors

References (&) and mutable references (&mut) — using a value without moving ownership. What the borrow rule "any number of shared references, or exactly one mutable reference" actually prevents (mutation during iteration, data races), how to read and fix the cannot borrow as mutable error, how dangling references get blocked at compile time, and finally &str and slices.

SQLAlchemy 2.0 #3 Defining ORM Models: DeclarativeBase, Mapped, mapped_column
4 min read

SQLAlchemy 2.0 #3 Defining ORM Models: DeclarativeBase, Mapped, mapped_column

The 2.0-style way of declaring tables as Python classes: the DeclarativeBase inheritance structure, how Mapped type hints and mapped_column divide the work, the rules mapping Python types to database types, how Optional drives nullable, declaring defaults, unique constraints, and indexes, and the naming convention that gives constraints predictable names from day one.

Rust Basics #3 Ownership: Move by Default, and How Memory Is Freed Without a GC
5 min read

Rust Basics #3 Ownership: Move by Default, and How Memory Is Freed Without a GC

Head-on with the heart of Rust: ownership. The three rules that give every value exactly one owner, why a value moves on assignment or a function call and the original variable becomes unusable, the Copy privilege reserved for fixed-size stack types, clone as a copy whose cost is visible in the code, and drop at the end of scope — the structure that turns use-after-free into a compile error.

SQLAlchemy 2.0 #2 Engines and Transactions: Connection Pools and the Two Commit Patterns
5 min read

SQLAlchemy 2.0 #2 Engines and Transactions: Connection Pools and the Two Commit Patterns

The foundation of SQLAlchemy: engines and transactions. Why connection pools exist and how they behave, what pool_size and max_overflow actually limit, the commit-as-you-go and begin-once patterns split between connect() and begin(), why transactions never auto-commit, defining tables with MetaData and Table, and running CRUD with Core expressions.

Rust Basics #2 Variables and Types: let and mut, Shadowing, Functions That End in Expressions
5 min read

Rust Basics #2 Variables and Types: let and mut, Shadowing, Functions That End in Expressions

Starting from what immutable-by-default let means and the explicit mut that opts out of it. Why shadowing — redeclaring the same name — is an everyday idiom, the scalar types (integers, floating point, bool, char) and overflow behavior, tuples and arrays, and the return rule where a single semicolon decides whether something is a statement or an expression.