{"repo":"artofhuman/django-pg-upsert","free":true,"listed":false,"github":"https://github.com/artofhuman/django-pg-upsert","clone":"git clone https://github.com/artofhuman/django-pg-upsert.git","description":"Support Postgres native upsert (INSERT ... ON CONFLICT) for django","language":"Python","stars":31,"topics":["django","postgresql","pyhton","hacktoberfest","sql"],"license":"MIT","category":"databases-storage","readme_excerpt":"django-pg-upsert This package adds support for the native Postgres upsert (INSERT ... ON CONFLICT) to Django. Installation pip install django-pg-upsert Usage As a manager This code produces the SQL statement: Explicit constraint name Using field names As a standalone function Update or Update with condition The update where argument restricts which existing rows are updated ( ON CONFLICT ... DO UPDATE SET ... WHERE ... ). It accepts a Q object. The argument also accepts a raw SQL string. Use a raw string to reference the proposed row through EXCLUDED . Do not build a raw string from user input. The package inlines the string into the statement as is. Batch To insert many rows in one statement, pass a list. The manager accepts a list of dictionaries. The standalone function accepts a list of model objects. All other arguments work as they do for a single row. or Both calls produce one statement with one row set for each object: Motivation django-postgres-extra also has a pg upsert method, but that package requires a different DB backend in the Django settings. Sometimes this change is not possible. django-pg-upsert solves only one problem and depends only on Django. It is not a Swiss army knife.","default_branch":null,"files":null,"tree":[],"storefront":"/r/artofhuman","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/artofhuman/django-pg-upsert/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}