Tuesday, September 25, 2018

Re: django ORM with asyncio

Hi Andrew,
thanks for your reply, well to be honest I'm a bit surprised / honored to get the answer directly from the creator of South.

Anyhow, aiopg is not the only option, I noticed that there are also asyncpg and aiopg8000.
My question is: 
even creating a new database wrapper, how can I modify the connection used by the ORM 'on-the-fly' (e.g. only during a management command, that would one of the few occasions where mixing AsyncIO with Django can be handy IMHO)? 
and that would be enough to use the ORM asynchronously? 

I mean if it's possible with SQLAlchemy there should be a way to achieve the same thing with the Django ORM...



Il giorno martedì 18 settembre 2018 23:17:53 UTC+2, Andrew Godwin ha scritto:
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.

Andrew

On Tue, Sep 18, 2018 at 5:55 AM luke lukes <lordl...@gmail.com> wrote:

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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2af17ca1-6d48-45b0-9406-37e046934567%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c01a5553-6bff-4513-b8f2-1b3eaa87e17f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment