- Added Python 3.13 support, dropped Python 3.8. Added Postgres17 support by @wesleykendall in #49.
- Add support for db defaults in
pgbulk.upsert
by @max-muoto in #42. - Support binary mode for
pgbulk.copy
by @max-muoto in #45
- Remove elipses defaults on overloads to avoid incorrect resolution by @max-muoto in #41.
- Add overloads on
upsert
,aupsert
,update
, andaupdate
to improve type-checking onreturning=...
by @max-muoto in #40.
-
The
redundant_updates
flag forpgbulk.upsert
was renamed toignore_unchanged
, and the default behavior was flipped by @wesleykendall in #38.Unlike before, unchanged rows are not ignored by default. See the pull request for a guide on how to update invocations from version 2.
-
Support update expressions,
returning
, andignore_unchanged
inpgbulk.update
by @wesleykendall in #38pgbulk.update
's interface has reached feature parity withpgbulk.upsert
, allowing for returning results, ignoring unchanged rows from being updated, and bulk updates with expressions. -
New
pgbulk.copy
function that leveragesCOPY ... FROM
by @wesleykendall in #39pgbulk.copy
wraps Postgres'sCOPY ... FROM
to insert data. Can be dramatically faster than Django'sbulk_create
.
- Django 5.1 compatibilty, dropped Django 3.2 / Postgres 12 support by @wesleykendall in #37.
- Fix typing errors allowing for strict type-safety with Pyright. [Maxwell Muoto, 8158596]
-
Fix operations on virtual and generated fields. [Darlin Alberto, 852a492]
Using non-concrete fields such as django-hashids HashidsField and the new Generatedfield in Django 5 previously produced errors during upsert and update operations. These fields are now fully supported.
- Update with the latest Python library template. [Wesley Kendall, 6a00a64]
- Fix ReadTheDocs builds. [Wesley Kendall, 93965a9]
-
Add
exclude
arguments topgbulk.upsert
andpgbulk.update
. [Maxwell Muoto, cde5904]Add
exclude
arguments topgbulk.upsert
andpgbulk.update
.Users can now use
exclude=["field_name"]
to exclude fields for updating or upserting data.
-
Django 5.0 compatibility [Wesley Kendall, e7848ed]
Support and test against Django 5 with psycopg2 and psycopg3.
- Add py.typed file, fix typing issues [Maxwell Muoto, 76f6e77]
-
Allow updates on custom primary key fields [Wesley Kendall, 4dbfb1c]
pgbulk.update
would fail on models with custom primary key fields when noupdate_fields
argument was supplied. This has been fixed.
- Improve base type annotations, avoid type annotations in comments [Maxwell Muoto, 862e253]
- Added Opus10 branding to docs [Wesley Kendall, c2f9d18]
- Add additional docs and notes around async usaged and model signals. [Wesley Kendall, 4cce843]
- Fix release notes [Wesley Kendall, 8a88b7a]
-
Python 3.12 / async support, dropping of
pgbulk.sync
andreturn_untouched
[Wesley Kendall, de70607]This version of
django-pgbulk
breaks the API in the following manner:pgbulk.upsert
no longer supports thereturn_untouched
argument. It had race conditions and will only be brought back if those race conditions can be addressed.pgbulk.upsert
'signore_duplicate_updates
was renamed toredundant_updates
. The default functionality is still the same, but the argument now has the opposite meaning.pgbulk.sync
was dropped since it relied on thereturn_untouched
argument.
This release also includes the following changes:
- Python 3.12 is supported and Python 3.7 is dropped
- Postgres 16 support
- Async-compatible
pgbulk.aupsert
andpgbulk.aupdate
were added - New documentation theme and formatting with Material for Mkdocs
- Type annotations for public functions and classes
-
Added Python 3.11, Django 4.2, and Psycopg 3 support [Wesley Kendall, f606b0b]
Adds Python 3.11, Django 4.2, and Psycopg 3 support along with tests for multiple Postgres versions. Drops support for Django 2.2.
-
Sort bulk update objects [Wesley Kendall, f766617]
Objects passed to
pgbulk.update
are now sorted to reduce the likelihood of a deadlock when executed concurrently.
- Updated with latest Python template [Wesley Kendall, 9652cd2]
- Updated with latest Django template [Wesley Kendall, 6ef27e6]
- Test against Django 4.1 and other CI improvements [Wes Kendall, 9eedff4]
- Fix ReadTheDocs builds [Wes Kendall, 15832a5]
- Updated with latest Django template [Wes Kendall, 4e9e095]
- Fix release note rendering and code formatting changes [Wes Kendall, 94f1192]
- README and intro documentation fix [Wes Kendall, e75930e]
- Updated with latest Django template, fixing doc builds [Wes Kendall, c3ed424]
-
Handle func-based fields and allow expressions in upserts [Wes Kendall, 64458c5]
pgbulk.upsert
allows users to provide apgbulk.UpdateField
object to theupdate_fields
argument, allowing a users to specify an expression that happens if an update occurs.This allows, for example, a user to do
models.F('my_field') + 1
and increment integer fields in apgbulk.upsert
.Along with this, fields that cast to
Func
and other expressions are properly handled during upsert.
- Updates to latest template, dropping py3.6 support and adding Django4 support [Wes Kendall, 35a04b0]
-
Fix error when upserting custom AutoFields [Wes Kendall, 114eb45]
upsert()
previously errored when using a custom auto-incrementing field. This has been tested and fixed.
- Updated with the latest Django template [Wes Kendall, 71a2678]
- Update with the latest public django app template. [Wes Kendall, 271b456]
-
Initial release of django-pgbulk. [Wes Kendall, 7070a26]
The initial release of django-pgbulk includes three functions for bulk operations in postgres:
pgbulk.update
- For updating a list of models in bulk. Although Django provides abulk_update
in 2.2, it performs individual updates for every row and does not perform a native bulk update.pgbulk.upsert
- For doing a bulk update or insert. This function uses postgresUPDATE 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.pgbulk.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.