PyCon Portugal 2026

SQLAlchemy ORM: Building a Production-Grade Commodity Pricing API Without Raw SQL

Managing a database and keeping application data in sync can become complex as Python applications grow. In this hands-on workshop, you’ll learn how to use SQLAlchemy ORM to structure database interactions and build clean, maintainable Python APIs. We will use a commodity pricing API as a practical example to demonstrate how real-world systems are designed.

We’ll cover how SQLAlchemy’s Object Relational Mapper (ORM) replaces scattered raw SQL with structured Python models, making database operations more consistent and easier to manage. Participants will learn how to define ORM classes, model relationships, and work with efficient query patterns.

We will also explore SQLAlchemy’s asyncio extension to show how modern Python applications interact with databases asynchronously.

Participants will leave with practical experience building a working API and a clear understanding of how to structure database-backed Python applications using SQLAlchemy ORM.


Managing a database and keeping application data in sync with the database can be tricky as Python applications grow in complexity. In many systems, raw SQL scattered across the codebase leads to tight coupling, reduced maintainability, and inconsistent data handling.

In this hands-on workshop, you’ll learn how to use SQLAlchemy ORM to simplify database interactions and structure clean, maintainable Python APIs. We will build a commodity pricing API as a practical example to demonstrate how ORM-based design works in real applications.

We’ll cover how SQLAlchemy’s Object Relational Mapper (ORM) system helps replace raw SQL with structured Python models, making database operations more readable and easier to maintain. Participants will learn how to define ORM classes that represent database tables, manage relationships between models, and work with efficient querying techniques.

We will also explore relationship-loading strategies to understand how query behavior affects performance in real systems, and how to apply SQLAlchemy’s asyncio extension in modern Python services.

By the end of this tutorial, participants will walk out having learned how to:

1. Use SQLAlchemy ORM to perform database operations in Python without relying on raw SQL
2. Design and implement ORM models that map directly to relational database tables
3.Manage database sessions and transactions correctly in real Python applications
4.Model relationships between entities and apply different relationship-loading strategies to control query behavior and performance
5. Use SQLAlchemy’s asyncio extension to build asynchronous database-backed Python services
6. Structure a complete API workflow using SQLAlchemy ORM (using a commodity pricing API as a practical example)

Audience Level: Intermediate What are the main topics of your talk?:

SQLAlchemy, ORM, Asyncio, API Design, Database Architecture, Python Performance, Backend Development.