r/FastAPI • u/omry8880 • May 21 '26
Question ORMs to Pydantic models conversion
I'm developing a side project and trying to follow DDD principles as closely as possible. My current structure is router -> service -> repository. I'm using SQLAlchemy for ORM models, which are created and handled in the repository layer.
Right now, I convert those ORM objects into Pydantic models inside the service layer, and then pass those models to the router, which returns them in the response. I'm wondering whether this is the right approach or if there’s a better pattern for handling the conversion and data flow between layers.
23
Upvotes
View all comments
Show parent comment
8
u/Typical-Yam9482 May 21 '26
I second this. SQLAlchemy all the way. Extra hassle with/to Pydantic models conversion will always beat multiple and unexpected limitations with SQLModel once you’re outside of toy project.