Registry / database / django-pgbulk

django-pgbulk

JSON →
library3.3.0pypypiunverified

Native PostgreSQL bulk update, upsert, and copy operations for Django. Current version 3.3.0, supports Python >=3.10, Django 5.x/6.x, Postgres 12-18. Regular releases every few months.

pip install django-pgbulk
INSTALL
IMPORT
SIG · DJANGO-PGBULK
D
django-pgbulk
databasepythonv3.3.0
Install
3.4s avg
Import
Disk
65MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 66.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.4s · import 0.000s · 67MB
65MB installed
● package 65MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

upsert
from pgbulk import upsert
from pgbulk import upsert

Bulk upsert (INSERT ... ON CONFLICT DO UPDATE) for a Django model.

from pgbulk import upsert from myapp.models import MyModel data = [ {'id': 1, 'name': 'Alice', 'age': 30}, {'id': 2, 'name': 'Bob', 'age': 25}, ] # Upsert using 'id' as conflict target upsert(MyModel, data, conflict_target=['id']) print('Success')
Debug
Known issues
breakingIn v3.0.0, the `redundant_updates` flag was renamed to `ignore_unchanged` and the default behavior flipped. Previously, redundant updates were skipped by default; now they are applied unless `ignore_unchanged=True`.
fix
Replace `redundant_updates=True` with `ignore_unchanged=True`. If you relied on the old default, set `ignore_unchanged=True` explicitly.
affects: >=3.0.0
deprecatedPython 3.9 support dropped in v3.3.0. Django 4.2 is the last version with Python 3.9 support.
fix
Upgrade Python to 3.10+. Use Django 4.2 LTS if stuck on Python 3.9.
affects: >=3.3.0
gotchaThe `bulk_update` function uses Postgres UPDATE FROM, which requires the model's fields list. If you omit fields, it raises `ValueError: fields must be provided`.
fix
Always provide the `fields` argument to `bulk_update`, e.g. `pgbulk.bulk_update(MyModel, data, fields=['name', 'age'])`
affects: all
Upgrade
Version history
3.3.0latest on PyPI · released Nov 30, 2025
Audit
Dependencies
DjangorequiredRequired as a peer dependency
psycopg2optionalFor PostgreSQL connections
Agent activity
8 hits · last 30 days
node
8
Resources
django-pgbulk — pip install django-pgbulk · libregistry