7

I'm looking for something that can allow the usage of the Django ORM with asyncio (with PostgreSQL). As of now I found only aiopg in the asyncio ecosystem, which allows to run raw SQL or to use SQLAlchemy only.

I then found something in the django channels docs. is this:

https://github.com/django/channels/blob/master/channels/db.py

the missing piece that I was looking for?

Thanks

Luke
  • 1,794
  • 10
  • 43
  • 70
  • It looks like that module uses threads to close old database connections. It has nothing to do with/no knowledge of asyncio. – dirn Sep 18 '18 at 13:00
  • If you write your endpoints within channels you can then `await` Django ORM operations yes. – Matthaus Woolard Sep 27 '18 at 10:36
  • 3
    @MatthausWoolard Andrew Godwin himself replied to me to the same question asked on the google django users group: *** The Django ORM can't just be used with asyncio directly, sadly. The database_sync_to_async function you found there will help you call the ORM from asynchronous code, but it still runs the ORM in a synchronous thread (see https://channels.readthedocs.io/en/latest/topics/databases.html) The project to make the ORM truly async is a tough one and yet to be started. *** – Luke Sep 27 '18 at 19:22

0 Answers0