r/FastAPI • u/00001sam10000 • Jan 08 '25
Question What's the benefit of sqlmodel in fastapi?
I think using sqlalchamy is enough so why using sqlmodel especially when it adds another extra layer; what's the benefti?
16
Upvotes
View all comments
Show parent comment
1
u/bluewalt Jan 09 '25
If you have a SQLModel used only as a table, and many SQLModels used as input/output serializers, then it does not bring anything compared to having a SQLAlchemy model + Pydantic models. You can not say "it's neat" just because it inherits from the same base class or live in the same file, because it the end, it behave very differently, because of this
table=Trueattribute.