{"repo":"kraken-tech/django-integrity","free":true,"listed":false,"github":"https://github.com/kraken-tech/django-integrity","clone":"git clone https://github.com/kraken-tech/django-integrity.git","description":"Tools for refining Django's IntegrityError, and working with deferred database constraints.","language":"Python","stars":26,"topics":["django","postgresql","python"],"license":"BSD-3-Clause","category":"databases-storage","readme_excerpt":"Django Integrity Django Integrity contains tools for controlling deferred constraints and handling IntegrityError s in Django projects which use PostgreSQL. Deferrable constraints Some PostgreSQL constraints can be defined as DEFERRABLE . A constraint that is not deferred will be checked immediately after every command. A deferred constraint check will be postponed until the end of the transaction. A deferrable constraint will default to either DEFERRED or IMMEDIATE . The utilities in django integrity.constraints can ensure a deferred constraint is checked immediately, or defer an immediate constraint. These alter the state of constraints until the end of the current transaction: - set all immediate(using=...) - set immedate(names=(...), using=...) - set deferred(names=(...), using=...) To enforce a constraint immediately within some limited part of a transaction, use the immediate(names=(...), using=...) context manager. Why do we need this? This is most likely to be useful when you want to catch a foreign-key violation (i.e.: you have inserted a row which references different row which doesn't exist). Django's foreign key constraints are deferred by default, so they would normally raise an error only at the end of a transaction. Using try to catch an IntegrityError from a foreign-key violation wouldn't work, and you'd need to wrap the COMMIT instead, which is trickier. By making the constraint IMMEDIATE , the constraint would be checked on INSERT , and it would be much easi","default_branch":null,"files":null,"tree":[],"storefront":"/r/kraken-tech","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/kraken-tech/django-integrity/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."}