Skip to main content
Django ORM + Twisted + asyncio - blocking
----------------------------------------
This is a library that contains a custom queryset and a custom manager that adds introspection to use
the twisted database api instead of django. It returns deferred (Future or coroutine) instead of just hitting the database.


since v0.6:
-----------
- added support for django_bulk_update (github.com/aykut/django-bulk-update)


since v0.5:
-----------
- model instance save method replacing on the fly, now u can:
```python
await obj.save()
```

since v0.3-0.4:
-----------
- get_or_create fix


since v0.2:
-----------
- mostly rewrited;
- renamed package as "twisted-django-orm";
- python 3.5.2+ now is required;
- used asyncio to avoid "callback hell";
- you still can obtain result as defered;
- there are some untested cases;


To install:
-----------
Python 3.5.2+ is required

1. pip install twango
2. Import and set the manager as the manager for any model (see examples)
3. Use it on the top of the twisted and asyncio

This will keep the orm from blocking when using the django orm!

Important
-----------
Does not make job in asynchronous way, but goes into threads and do not perform blocking main reactor.

Example 352+:
--------
```python

q = await Operation.twisted.all()[:5].fetch()
print(q)

b = await Operation.twisted.all().fetch()
print(b[5])

async for x in Operation.twisted.all().order_by('cell', 'status'):
print(x.price, x.status, x.cell)

async for x in Operation.twisted.all().order_by('cell', 'status')[:5]:
print(x.price, x.status, x.cell)

x = await Operation.twisted.get(price=3000, status=1, cell=11)
print(x)

p = await Operation.twisted.count()
print(p)

x, created = await Operation.twisted.update_or_create(defaults={'cell': 11, 'price': 333}, price=1, status=1, cell=25)
print(x)

x, _created = await Operation.twisted.get_or_create(price=27, status=1, cell=11)
print(x)
```

Example (old):
--------
You can create models that are separate to be used in twisted processes:

```python
from myapp import Book
from twango.manager import TwistedManager
from django.db.models.manager import Manager

class TwistedBook(Book):
objects = Manager()
twisted = TwistedManager()

class Meta:
app_label = 'myapp'
proxy = True
```

Metadata

Release files for djangotworm 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djangotworm 0.6.1
File Size Uploaded
djangotworm-0.6.1.tar.gz 6.6 kB Details

Release files / djangotworm-0.6.1.tar.gz

Download URL djangotworm-0.6.1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fb6c70f62d9d6aaa0942e591604f54ec83c5600e5c7373d5b8c4c9b1a663fbaa
BLAKE2b-256 checksum
How to use checksums
84089cacb83d0fae232fd45e209e40af9e743c8666e9185e0b334d7683bfc6ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.6.1 This release

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page