Mastodon

Connecting Your Backend to a Database

by Kristian Rother

Monday, 19 April 2027, 9:00–16:00 (lunch break 12:00–13:00) · 6 hours

Repository Pattern DuckDB SQLModel MongoDB

Connecting Your Backend to a Database — Full-Day Masterclass

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.

Who Should Attend

This masterclass is for developers who already write Python code regularly and want to level up their backend engineering. You should be comfortable with:

  • Python functions, classes and type hints
  • Basic HTTP/REST concepts
  • Reading and writing straightforward SQL is helpful, but not required

What You'll Learn

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

What to Bring

Please bring a laptop with:

  • Python 3.13+
  • uv installed
  • Optionally, a working Docker installation (Docker Desktop or Docker Engine)

Your trainer: 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. He is not too nervous about AI adoption, since the challenging parts are still challenging. His favorite Python module is re. Kristian believes everybody can learn programming.

You can find Kristian's teaching materials on academis.eu.