Primary Authors
@wesleykendall (Wes Kendall)
Native postgres bulk update and upsert operations.
django-pgbulk, forked from django-manager-utils, provides several optimized bulk operations for Postgres:
update - For updating a list of models in bulk. Although Django provides a bulk_update in 2.2, it performs individual updates for every row and does not perform a native bulk update.
upsert - For doing a bulk update or insert. This function uses postgres UPDATE ON CONFLICT syntax to perform an atomic upsert operation. There are several options to this function that allow the user to avoid touching rows if they result in a duplicate update, along with returning which rows were updated, created, or untouched. Users can also use models.F objects on conflicts.
sync - For syncing a list of models with a table. Does a bulk upsert and also deletes any rows in the source queryset that were not part of the input data.
For more examples, see the django-pgbulk docs.
Install django-pgbulk with:
pip3 install django-pgbulk
After this, add pgbulk to the INSTALLED_APPS setting of your Django project.
For information on setting up django-pgbulk for development and contributing changes, view CONTRIBUTING.rst.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83e59a4890d6268167fe1279dace280d8972a65ad77c753db763024a858b5347 |
|
MD5 | 69888ca329e7040ddea6b0a80838e6b3 |
|
BLAKE2b-256 | 995b8c80f48cc60b8ac49bbb280cdd8c8ab8bd8b7add4a326ff6a0d9ffee5aa7 |