Bulk update for django.
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**.
Usage
==================================
With manager:
from bulk_update.manager import BulkUpdateManager
class PersonManager(BulkUpdateManager):
pass
class Person(models.Model):
...
objects = PersonManager()
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
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
Installation
==================================
Requirements
==================================
Django 1.2+
TODO
==================================
- Add batch_size option.
==================================
Simple bulk update over Django ORM or with helper function.
This project aims to bulk update given objects using **one query** over **Django ORM**.
Usage
==================================
With manager:
from bulk_update.manager import BulkUpdateManager
class PersonManager(BulkUpdateManager):
pass
class Person(models.Model):
...
objects = PersonManager()
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
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
Installation
==================================
Requirements
==================================
Django 1.2+
TODO
==================================
- Add batch_size option.
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
django-bulk-update-0.1.tar.gz
(2.6 kB
view hashes)
Built Distribution
Close
Hashes for django-bulk-update-0.1.macosx-10.9-intel.exe
Algorithm | Hash digest | |
---|---|---|
SHA256 | f06f58e27743d3ae2a4d79563108b3c8681b6a422ba673d7053fa0abec9a5ce3 |
|
MD5 | 95f0008c8223931dbfa1956f39d0fa58 |
|
BLAKE2b-256 | d5b311b57c0c3a6e35c84ef60a2519dd2cae6742022bc46e2057cc50762bcb33 |