Bulk update using one query over Django ORM.
Project description
django-bulk-update
==================================
Simple bulk update over Django ORM or with helper function.
This project aims to bulk update given objects using **one query** over **Django ORM**.
Installation
==================================
pip install django-bulk-update
Usage
==================================
With manager:
from bulk_update.manager import BulkUpdateManager
class Person(models.Model):
...
objects = BulkUpdateManager()
random_names = ['Walter', 'The Dude', 'Donny', 'Jesus']
people = Person.objects.all()
for person in people:
r = random.randrange(4)
person.name = random_names[r]
Person.objects.bulk_update(people, update_fields=['name']) # updates only name column
Person.objects.bulk_update(people, exclude_fields=['username']) # updates all columns except username
Person.objects.bulk_update(people) # updates all columns
Person.objects.bulk_update(people, batch_size=50000) # updates all columns by 50000 sized chunks
With helper:
from bulk_update.helper import bulk_update
random_names = ['Walter', 'The Dude', 'Donny', 'Jesus']
people = Person.objects.all()
for person in people:
r = random.randrange(4)
person.name = random_names[r]
bulk_update(people, update_fields=['name']) # updates only name column
bulk_update(people, exclude_fields=['username']) # updates all columns except username
bulk_update(people, using='someotherdb') # updates all columns using the given db
bulk_update(people) # updates all columns using the default db
bulk_update(people, batch_size=50000) # updates all columns by 50000 sized chunks using the default db
Requirements
==================================
- Django 1.2+
TODO
==================================
- UnitTests
- Performance Tests
==================================
Simple bulk update over Django ORM or with helper function.
This project aims to bulk update given objects using **one query** over **Django ORM**.
Installation
==================================
pip install django-bulk-update
Usage
==================================
With manager:
from bulk_update.manager import BulkUpdateManager
class Person(models.Model):
...
objects = BulkUpdateManager()
random_names = ['Walter', 'The Dude', 'Donny', 'Jesus']
people = Person.objects.all()
for person in people:
r = random.randrange(4)
person.name = random_names[r]
Person.objects.bulk_update(people, update_fields=['name']) # updates only name column
Person.objects.bulk_update(people, exclude_fields=['username']) # updates all columns except username
Person.objects.bulk_update(people) # updates all columns
Person.objects.bulk_update(people, batch_size=50000) # updates all columns by 50000 sized chunks
With helper:
from bulk_update.helper import bulk_update
random_names = ['Walter', 'The Dude', 'Donny', 'Jesus']
people = Person.objects.all()
for person in people:
r = random.randrange(4)
person.name = random_names[r]
bulk_update(people, update_fields=['name']) # updates only name column
bulk_update(people, exclude_fields=['username']) # updates all columns except username
bulk_update(people, using='someotherdb') # updates all columns using the given db
bulk_update(people) # updates all columns using the default db
bulk_update(people, batch_size=50000) # updates all columns by 50000 sized chunks using the default db
Requirements
==================================
- Django 1.2+
TODO
==================================
- UnitTests
- Performance Tests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-bulk-update-1.0.1.macosx-10.9-intel.exe
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ee23ac20b3caa24e10a58be9a809029f2ecd0898d785f2112457ebcdb7baeca |
|
MD5 | 757bd4d67af04afc5f337f68a6f0fa4e |
|
BLAKE2b-256 | 5a72a78c803b58ef472ff4d4b212733f0b6cee3075d2d8402e8a3d60a7fe982d |