Decoupled Data: Architecting Clean and Reliable Database Connections in Python
by Dr. Kristian Rother
Friday, 17 April 8:00 - 16:30 (lunch break 12:00-13:00) incl. breaks · 2 x 3.5 hours
In this masterclass, you will build a production-grade Python REST API that connects cleanly and reliably to a database—without turning persistence into a tangled cross-cutting concern. Starting from a minimal API, we will design a persistence layer using the Repository Pattern, then implement and compare three concrete approaches:
- Raw SQL using DuckDB (explicit control, predictable performance)
- ORM with sqlmodel (developer ergonomics, complex query trade-offs)
- NoSQL with MongoDB (schema flexibility, consistency implications)
Along the way, we will focus on engineering decisions that matter in real systems: data validation, idempotency, incremental updates, and integration testing in a containerized environment. You will leave with a working reference implementation and many aspects worth considering in your next project.
Learning Outcomes
By the end of the masterclass, you will be able to:
- Design a clean persistence boundary using the Repository Pattern
- Implement the same API persistence layer with SQL, ORM, and NoSQL approaches
- Apply robust validation and update strategies that avoid subtle bugs
- Implement idempotency patterns suitable for real-world services
- Create a Docker-based integration test setup
- Write meaningful tests
Dr. Kristian Rother
Kristian is a freelance Python trainer who wrote his first lines of Python in the year 11111001111. After a career writing software for life science research, he has been teaching Python, Data Analysis and Machine Learning throughout Europe since 2011. More recently, he has built data pipelines for the real estate and medical sector.
Kristian has translated 5 Python books and written 2 more himself, in addition to numerous teaching guides. Kristian has collected 364 stars on Advent of Code. His favorite Python module is 're'. Kristian believes everybody can learn programming.