r/FastAPI • u/Ok_Opportunity6252 • Oct 31 '25
Question __tablename__ error
Type "Literal['books']" is not assignable to declared type "declared_attr[Unknown]"
"Literal['books']" is not assignable to "declared_attr[Unknown]" Pylance
What does it mean? And why is the error? This is how SQLAlchemy docs do things
23
Upvotes
View all comments
Show parent comment
6
u/Typical-Yam9482 Oct 31 '25
There are same amount of youtubers who pitch SQLAlchemy with FastAPI. The ones you watch do this because these tutorials are on FastAPI site. So, they just "read" it aloud.
SQLAlchemy has army of supporters, production-proven, extremely optimized (you can still do "stupid" N+1 things though, if you "vibe code" or not genuinely curious how things works). It gives you way better flexibility and so on.
So, you have two ways: keep SQLModel and just do project and be happy if it works for you
Do above, but come to certain level of medium complexity when you realize SQLModel just simply cannot do this and... switch to SQLAlchemy at last.
If you are not convinced: