3 ms·
> Full support for Django and particularly it’s ORM (hard to do with FastAPI as the ORM is not yet async) I think you may have it backwards. Django's ORM isn't
by vladvasiliu 5y ago
> Full support for Django and particularly it’s ORM (hard to do with FastAPI as the ORM is not yet async)
I think you may have it backwards. Django's ORM isn't async yet [1], whereas FastAPI doesn't actually have an "included" ORM. However, the docs give an example of an async ORM [2], and SQLAlchemy also has async support [3].
---
[1] https://docs.djangoproject.com/en/4.0/topics/async/ https://docs.djangoproject.com/en/4.0/topics/async/: We’re still working on async support for the ORM
[2] https://fastapi.tiangolo.com/advanced/async-sql-databases/ https://fastapi.tiangolo.com/advanced/async-sql-databases/
[3] https://docs.sqlalchemy.org/en/14/orm/extensions/asyncio.html https://docs.sqlalchemy.org/en/14/orm/extensions/asyncio.htm...
- samwillis 5y agoNo, sorry, did have it right but wasn't clear in my sentence: Full support for Django and particularly it’s ORM (hard to do with FastAPI as the Django ORM is not yet async and can’t be used with FastAPI) Will edit to make clear.
- bryanh 5y agoThis isn’t exactly true. The Django ORM can be used with care in the async views found in FastAPI and Django (see sync_to_async and run_in_threadpool helpers). Plans exist to make the Django Queryset async, so it’ll be exciting when that day comes!
- samwillis 5y agoVery true, and I have been following this pull request implementing Async Queryset with interest: https://github.com/django/django/pull/14843 https://github.com/django/django/pull/14843 So far they are only going down the the queryset level, it then uses a thread pool for the db connector, next job would be to support async db connections.
- cmclaughlin 5y agoThe author of FastApi wrote an ORM too: https://github.com/tiangolo/sqlmodel https://github.com/tiangolo/sqlmodel I have not yet used it, but I think that’s the best approach now
- codingkev 5y agoWhats the deal with they large number of open issues an pull requests on FastAPI and SQLModel? SQLModel 100 issues, 54 open PRs FastAPI 903 issues, 448(!!) open PRs I recently had to choose between Flask and FastAPI for a fresh project and went with Flask in the end, partly due to long term maintenance concerns with FastAPI.
- samwillis 5y agoThere was a recent discussion about it here including a reply from the FastAPI creator explaining the situation: https://news.ycombinator.com/item?id=29471609 https://news.ycombinator.com/item?id=29471609
- zeppelin101 5y agoHaving given SqlModel a very proper go a few months back, I have to say that it's not worth using it just yet. There are too many outstanding issues and the documentation is also incomplete. Maybe in a year's time, the situation could be different.
- etimberg 5y agoA good Django like ORM for FastAPI is Ormar [1]. I've got PG specific extensions to Ormar in [2]. 1. https://github.com/collerek/ormar https://github.com/collerek/ormar 2. https://github.com/tophat/ormar-postgres-extensions/ https://github.com/tophat/ormar-postgres-extensions/