A Django model manager providing insert on conflict for PostgreSQL database tables.
Project description
Introduction
Django ORM manager for Postgresql Came from Rock@luojilab
Replace update_or_create Without transaction, when using update_or_create may raise IntegrityError Because thread 1 execute update affect 0 row and at the same time, thread 2 insert it then thread 1 do insert will trigger UniqueKey conflict.
This method will use INSERT ON CONFLICT feature to fix this.
Requirements
Python >= 2.6
Django >= 1.7
PostgreSQL >= 9.2
Installation
Running following command:
$ python setup.py install
Or using pip:
to be continue
Usage
Python code:
from django.db import models from ioc import IOCManager class Test(models.Model): code = models.CharField(max_length=50, unique=True)) name = models.CharField(max_length=100 objects = IOCManager() Test.objects.create_or_update( conflict="code", code="luojilab", defaults={ "name": "LuojiLab", }, )
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
Close
Hashes for django_postgres_ioc-0.0.1-py3.6.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | d307867be9f81e4cbb4e291dc28a4fb86d36d908c12ad9c478cc27d027459831 |
|
MD5 | 074c9af80c9917f8440d25f3f8c1d934 |
|
BLAKE2b-256 | dd100cdd77c94edbd2ce2247b84b6a2a23963dda94c94d9fb23478f53f1a9ecf |
Close
Hashes for django_postgres_ioc-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b06457a04a7f42af5249a9f5ab2d0dc07ffb1c7fbe6f5619ffee69575ddd145e |
|
MD5 | a719461031b688f1880fe3c213d02f1a |
|
BLAKE2b-256 | 4e2c9c2a30ee35186f33b78717c5e20d6708846aae3b6863ccb01f78e03dcfc5 |