django-pg-bulk-update
Django extension, executing bulk update operations for PostgreSQL
What it is and what it does
django-pg-bulk-update is a Django extension that optimizes bulk update and create operations on PostgreSQL by generating raw SQL queries that handle multiple records with different values in a single database round-trip. It provides four main functions: bulk_update (updates multiple records), bulk_update_or_create (upsert pattern), bulk_create (creates multiple records), and pdnf_clause (builds complex OR-AND conditions as Django Q objects).
The package is designed for scenarios where you need to update or insert many rows with different field values based on key conditions—operations that would otherwise require multiple queries or loops. It supports advanced PostgreSQL features like JSONB operations, INSERT ON CONFLICT, and custom set functions (increment, concatenate, array operations). The library requires PostgreSQL 9.4+ and integrates with Django's ORM through custom managers or direct function calls.
Use it for:
- Batch-update user records with different status values based on user IDs in a single query.
- Perform upsert operations (insert or update) on large datasets using INSERT ON CONFLICT on PostgreSQL 9.5+.
- Increment numeric fields (e.g., counters) across multiple records without fetching and re-saving each one.
- Concatenate or merge array/JSONB fields across bulk records with custom set functions.
- Build complex multi-condition WHERE clauses (OR-AND combinations) using the pdnf_clause helper.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Executes bulk update and bulk create operations on PostgreSQL databases from Django, allowing efficient multi-record updates with conditional logic in a single query.
Yes, if you are using Django with PostgreSQL and need to perform bulk updates or upserts on many records efficiently. The low install friction and permissive license make it straightforward to adopt. However, note that maintenance is dormant (last release 775 days ago)—verify compatibility with your Django version before committing, and be aware of the documented race condition in bulk_update_or_create on PostgreSQL < 9.5.
Install
django-pg-bulk-update on PyPI
pip
pip install django-pg-bulk-updateuv
uv add django-pg-bulk-updatepoetry
poetry add django-pg-bulk-updateInstalling django-pg-bulk-update
Before you install
Low install friction with a pure-Python wheel distribution. Maintenance is dormant—last release was 775 days ago—but the repository remains active and unarchived. Relies on django, pytz, and typing as runtime dependencies, all standard.
License in practice
Licensed under BSD 3-clause, a permissive license with no restrictions on commercial or private use. You may modify and distribute freely provided you include the license notice.
Quickstart
pip install django-pg-bulk-update
from django_pg_bulk_update import bulk_update
# Update multiple records in one query
bulk_update(MyModel, {1: {'field': 'value'}, 2: {'field': 'value2'}})
Requires PostgreSQL 9.4+ as the backend database; psycopg2 or psycopg2-binary must be installed separately. Django 1.8+ required.
Verify before relying
- Whether the dormant maintenance status (775 days since last release) poses a risk for compatibility with recent Django versions.
- Whether the known race condition issue in bulk_update_or_create on PostgreSQL < 9.5 affects your use case.
- Performance characteristics compared to native Django bulk operations on modern PostgreSQL versions.
Package facts
| License | BSD 3-clause "New" or "Revised" License (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — django, pytz, typing |
| Maintenance | dormant — 775 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 183,078/month — #10,074 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_pg_bulk_update-3.7.3-py2.py3-none-any.whl
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
django-pg-returningExtends Django's ORM to capture and return rows…
permissive · top 15,000 on PyPI
django-bulk-updatePerforms bulk updates of Django ORM objects in…
permissive · top 15,000 on PyPI
django-postgres-copyProvides Django ORM integration for…
permissive · top 5,000 on PyPI
pgcopypgcopy wraps PostgreSQL's binary COPY protocol…
permissive · top 15,000 on PyPI
postgrestAn async Python client library that provides an…
permissive · top 1,000 on PyPI
salesforce-bulkPython client library for the Salesforce Bulk…
permissive · top 5,000 on PyPI
django-postgres-extraExtends Django's ORM to expose…
permissive · top 15,000 on PyPI
djangorestframework-bulkAdds bulk create, update, and delete operations…
permissive · top 15,000 on PyPI
django-query-builderBuilds and executes complex SQL queries…
permissive · top 15,000 on PyPI
django-chunkatorIterates over large Django QuerySets in…
permissive · top 15,000 on PyPI