---
title: "SQLAlchemy 2 In Practice - Chapter 2 - Database Tables"
url: https://daily.dev/posts/sqlalchemy-2-in-practice---chapter-2---database-tables-s1qrmn1pa
source_url: https://blog.miguelgrinberg.com/post/sqlalchemy-2-in-practice---chapter-1---database-tables
type: article
source: "Miguel Grinberg"
published: 2026-05-03T09:32:32.517Z
updated: 2026-05-03T09:33:53.477Z
tags: ["python", "backend", "sql"]
reading_time: 43
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# SQLAlchemy 2 In Practice - Chapter 2 - Database Tables

**[Miguel Grinberg](https://daily.dev/sources/miguelgrinberg)** · 43 min read · 0 upvotes · 0 comments

## Summary

A comprehensive chapter from Miguel Grinberg's SQLAlchemy 2 in Practice book covering the fundamentals of working with database tables using SQLAlchemy ORM. Topics include setting up the database engine, defining model classes with Python type hints, managing database metadata and naming conventions, using sessions for transactions, and executing queries with filters, ordering, aggregation, grouping, pagination, and indexes. Code examples use a RetroFun vintage computer catalog as a practical dataset throughout.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.miguelgrinberg.com/post/sqlalchemy-2-in-practice---chapter-1---database-tables>

## Similar posts on daily.dev

- [SQLAlchemy 2 In Practice - Chapter 8: SQLAlchemy and the Web](https://daily.dev/posts/sqlalchemy-2-in-practice---chapter-8-sqlalchemy-and-the-web-czkvocl80) · Miguel Grinberg · 1 upvotes · 0 comments
- [SQLAlchemy 2 In Practice - Chapter 7: Asynchronous SQLAlchemy](https://daily.dev/posts/sqlalchemy-2-in-practice---chapter-7-asynchronous-sqlalchemy-rwgj7jxq3) · Miguel Grinberg · 0 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#backend](https://daily.dev/tags/backend), [#sql](https://daily.dev/tags/sql)

[View this post on daily.dev](https://daily.dev/posts/sqlalchemy-2-in-practice---chapter-2---database-tables-s1qrmn1pa)
