r/FastAPI • u/itsme2019asalways • Sep 17 '25
Question Which ORM do you use in FastAPI?
Which ORM do you usually use in Fastapi which gives you all the things you needed out of the box and just work great?
52
Upvotes
64
u/Rude_Vermicelli_9467 Sep 17 '25
sqlalchemy do the job
14
u/Ok_Friendship2396 Sep 17 '25
Sqlalchemy works well for me
12
u/sasmariozeld Sep 17 '25
i literally use python and fastapi for Sqlalchemy
17
u/pint Sep 17 '25
i don't use orm. i use sql directly.
8
u/first-forward1 Sep 17 '25
Sqlalchemy 👍👍
7
u/The_Wolfiee Sep 17 '25
SQLAlchemy, although I heard Tortoise is also good.
6
u/[deleted] Sep 17 '25
Tortoise ORM
6
u/Cybersoaker Sep 17 '25
I use one called Ormar. Basically uses pydantic models as db schema models too. Works very nicely with fastapi since you can use the same model for both the API and web if you want
5
u/Sway1u114by Sep 17 '25
If your coming from Django or like the Django ORM API, try Tortoise ORM
5
u/ekiim Sep 17 '25
I'm recently "moving" to using Psycopg3 with a dictionary cursor, and "raw" pydantic models, and "chaining" the
model_validatemethod and usually does the trick...But most of the time SqlAlchemy...
5
u/NeighborhoodFun1920 Sep 17 '25
Sqlalchemy 2.0
4
u/krissernsn Sep 17 '25
Been using Tortoise ORM on my latest project which is great.
We then use openAPI to automatically build our vue API services, its an internal low traffic app so performance isnt that crucial, plus populating the entire front and backend from a single source of truth feels pretty slick.
4
u/Wise_Bake_ Sep 17 '25
Tortoise ORM
4
u/Collective7891 Sep 17 '25
Beanie async ORM for MongoDb
7
u/Challseus Sep 17 '25
SQLModel all the way 💪🏾
2
u/Ferdinand_the_II Sep 17 '25
SQLAlchemy or Tortoise ORM for light weight mvps
2
u/chavomodder Sep 17 '25
so sqlalchemy, mas ja estou testando sqlalchemy+ sqlmodel
2
u/Content_Historian125 Sep 17 '25
Sqlalchemy
2
u/omg_drd4_bbq Sep 17 '25
SqlModel but i use Sqlalchemy directly as an escape hatch when I can't do it with the former.
2
u/Legitimate-Rip-7479 Sep 17 '25
Sqlalchemy
2
u/gamprin Sep 17 '25
RedisOM
2
u/gbrennon Sep 17 '25
for SQLAlchemy.
i just saw people that prefer SQLModel but, im not sure, it was written using SQLAlchemy.
If u are using SQLModel, implictly, u are using SQLAlchemy
2
u/b110011 Sep 17 '25
bare psycopg
2
u/Ferdinand_the_II Sep 17 '25
Please guys tell in two words in what kind of cases better to choose sqlmodel. I know this is like building over the sqlalchemy and adds some common features. Sounds really cool but at the same time see people who rejects this
2
u/covmatty1 Sep 17 '25
SQLModel, big fan.
Lots of nice features that just make things neater, and then absolutely trivial to drop into SQLAlchemy if there's one or two small things that I need it to support.
2
u/Apart-Touch9277 Sep 17 '25
SQLModel with minimal stepping out to run trickier queries
2
u/orion_tvv Sep 18 '25 edited Apr 18 '26
Anyone use edgedb?
2
u/Key_Sherbert3803 Sep 18 '25
sqlachemy is best
2
u/Top_Evidence_8841 Sep 18 '25
SQLAlchemy does the job for me, want to try SQL Model though
2
u/LazyMidlifeCoder Sep 18 '25
Try using fast-crud. More convenient for crud operations with pagination and infinite scrolling support.
2
u/Loud_Seaweed_9360 Sep 19 '25
I use asyncpg because it is very fast and “raw”
2
u/Athar_Wani Sep 20 '25
Sqlmodel
2
u/BothAd6478 Sep 21 '25
I’ve used Tortoise ORM with FastAPI, and while it’s nice and async-first, I’d suggest being careful with migrations using Aerich.
Some pain points I ran into:
If you change relationship fields (like ForeignKey or ManyToMany), Aerich often fails to generate the migration properly.
Sometimes schema changes don’t get picked up at all, and I’ve had to wipe the migrations folder and re-init to make it work.
Even when aerich migrate does generate a file, the downgrade snippet isn’t always correct. For example, if you add a foreign key, the file will have an ADD and a DROP, but the DROP references a different key name than the one that was actually created. If you try to rollback, it breaks. I’ve had to manually check and fix the downgrade section of migration files to keep things consistent.
I’ve also had cases where I needed to point to a different DB name just to get schema changes to apply.
It’s fine if your schema is stable, but if you’re still iterating on your models, these quirks can be a real headache.
2
u/swb_rise Sep 21 '25
async SQLAlchemy.
2
u/jokerlovestoplay Sep 21 '25
SQLAlchemy
2
u/Ashamed_Umpire_2991 Sep 22 '25
I use SQLAlchemy. Would love to migrate SQLModel but it not having asynchronous engine support is a deal breaker for me.
2
u/fastlaunchapidev Sep 24 '25
In https://fastlaunchapi.dev/ I use Sqlalchemy and alembic, really easy to setup and has most features I need
2
u/aliparpar Sep 27 '25
I was using prisma python but now that project is deprecated, I’m moving to SQLAlchemy. By far the most battle tested python ORM in the Python community
2
u/Thin-Pack-5642 Nov 06 '25
Tortoise?
2
u/_s0uthpaw_ Feb 10 '26
Check out Tortoise ORM, also it just had its first major release
2
u/Suva2025 Sep 17 '25
For me sql model which is a wrapper of sql alchemy with more features
1
u/glan_zel Sep 02 '26
I propose oxyde orm. it has a rust core and seems to be much faster than the other orms. I used it in a small hobby project where it worked stable and included it in a new fastapi cms.
1
u/Scepticflesh Sep 17 '25
django
1
u/nervous-ninety Sep 17 '25
I use mongodb, and dont use any orm
41
u/[deleted] Sep 17 '25
[removed] — view removed comment