# Keeping the Data Code in One Place

A data module is the one file in an API that holds every SQL statement, with functions that take a connection and give back plain values (an id, a dictionary, a list, or None for a row that isn't there), so the routes call it and never write SQL themselves.

![Cheat sheet: Keeping the Data Code in One Place](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/a4424b52b1fb4651aba4f625ab9ea3d8.webp)

- Category: FastAPI
- Level: Journeyman
- Tags: Data Access Object (DAO), fastapi, Repository Pattern, rest-api, Separation of Concerns
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/fastapi-data-module-cheat-sheet
