--- id: django-pg-bulk-update version: "3.7.3" license: BSD 3-clause "New" or "Revised" License license_treatment: permissive maintenance: dormant --- # django-pg-bulk-update — Django extension, executing bulk update operations for PostgreSQL License: permissive · Maintenance: dormant · Downloads: 183.1K/mo ## 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 above — 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 pip install django-pg-bulk-update uv add django-pg-bulk-update poetry add django-pg-bulk-update ## Installing 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: unspecified - Install friction: low - Maintenance: dormant - Downloads: 183.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags django postgresql bulk update, batch update multiple records django, postgres bulk operations django, efficient mass update django orm, django bulk create insert, postgresql conditional batch update, django queryset bulk operations, django-extension, postgresql-optimization, bulk-operations [View on SkillFed](https://skillfed.io/packages/django-pg-bulk-update) · [View on PyPI](https://pypi.org/project/django-pg-bulk-update/)