{"id":23592,"library":"django-pgbulk","title":"django-pgbulk","description":"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.","status":"active","version":"3.3.0","language":"python","source_language":"en","source_url":"https://github.com/AmbitionEng/django-pgbulk","tags":["django","postgresql","bulk","upsert","copy"],"install":[{"cmd":"pip install django-pgbulk","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required as a peer dependency","package":"Django","optional":false},{"reason":"For PostgreSQL connections","package":"psycopg2","optional":true}],"imports":[{"note":"The package is 'pgbulk', not 'django_pgbulk'.","wrong":"from django_pgbulk import upsert","symbol":"upsert","correct":"from pgbulk import upsert"},{"note":"","wrong":"","symbol":"copy","correct":"from pgbulk import copy"}],"quickstart":{"code":"from pgbulk import upsert\nfrom myapp.models import MyModel\n\ndata = [\n    {'id': 1, 'name': 'Alice', 'age': 30},\n    {'id': 2, 'name': 'Bob', 'age': 25},\n]\n# Upsert using 'id' as conflict target\nupsert(MyModel, data, conflict_target=['id'])\nprint('Success')","lang":"python","description":"Bulk upsert (INSERT ... ON CONFLICT DO UPDATE) for a Django model."},"warnings":[{"fix":"Replace `redundant_updates=True` with `ignore_unchanged=True`. If you relied on the old default, set `ignore_unchanged=True` explicitly.","message":"In 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`.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Upgrade Python to 3.10+. Use Django 4.2 LTS if stuck on Python 3.9.","message":"Python 3.9 support dropped in v3.3.0. Django 4.2 is the last version with Python 3.9 support.","severity":"deprecated","affected_versions":">=3.3.0"},{"fix":"Always provide the `fields` argument to `bulk_update`, e.g. `pgbulk.bulk_update(MyModel, data, fields=['name', 'age'])`","message":"The `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`.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `from pgbulk import ...`","cause":"Installed package 'django-pgbulk' but import path is 'pgbulk'.","error":"ModuleNotFoundError: No module named 'pgbulk'"},{"fix":"Replace `redundant_updates=True` with `ignore_unchanged=True`.","cause":"`redundant_updates` was renamed to `ignore_unchanged` in v3.0.0.","error":"KeyError: 'redundant_updates'"},{"fix":"Add `fields=['field1', 'field2']` to the call.","cause":"Missing `fields` argument in `bulk_update`.","error":"ValueError: fields must be provided"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}