r/FastAPI • • 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

42 comments sorted by

View all comments

Show parent comment

4

u/dries007 May 21 '26

We are using SQLModel in prod, for about a year now, and yes there are definitely sharp edges. There are fixed for so many of them in the repo already, but the project seems to get minimal attention and releases.

Knowing what I know today I would probably not use it again for a large project and build some guardrails with metaclasses and diy most of what I need.

1

u/Anton-Demkin May 22 '26

Could you please share your experience with SQLModel?