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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-bulk-update-0.1.tar.gz.
File metadata
- Download URL: django-bulk-update-0.1.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a70ebbdb39b4c09acaa8074971415d10d43631035a244886c76a9d9c6630fbc
|
|
| MD5 |
7cddec8458d4309aee82bda7b49bfe54
|
|
| BLAKE2b-256 |
368c4534a3b36a0c80850aa148d694a417a3c24cf1409b2e5824e05cb712fdcc
|
File details
Details for the file django-bulk-update-0.1.macosx-10.9-intel.exe.
File metadata
- Download URL: django-bulk-update-0.1.macosx-10.9-intel.exe
- Upload date:
- Size: 66.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f06f58e27743d3ae2a4d79563108b3c8681b6a422ba673d7053fa0abec9a5ce3
|
|
| MD5 |
95f0008c8223931dbfa1956f39d0fa58
|
|
| BLAKE2b-256 |
d5b311b57c0c3a6e35c84ef60a2519dd2cae6742022bc46e2057cc50762bcb33
|