-
Notifications
You must be signed in to change notification settings - Fork 431
How to use asyncpg with django? #1116
-
I have been looking to implement async functionalities to my Django app to optimize the app performance. I'm looking for ways to use asyncpg in the Django app along with Django's built-in sync feature. I would greatly appreciate any suggestion.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
Currently, as per Django 5.0 release, Django ORM and most of Django itself is a synchronous framework where async functions are just sync functions wrapped into sync_to_async
. I encourage you to check them out, as even for DB transactions I had to write a similar wrapper.
So even if it could be possible to use asyncpg
as a driver via similar wrapper, it wouldn't be possible to gain any speed increase for it.
I don't mention that asyncpg
doesn't follow DB-API and this would be challenge similarly as it was for SQLAlchemy few years ago.
With Django project philosophy to be as stable as possible and backward compatible as possible, I don't expect any async conversion any time soon.
If you're still looking for such integration, Django project itself would be a better place to ask.
PS: above findings were for me a strong enough reason to switch to another framework entirely.
Beta Was this translation helpful? Give feedback.
All reactions
-
👎 1