Postgres audit triggers for Django
Project description
Postgres audit database via triggers
This app sets up a postgres audit database via triggers. See https://wiki.postgresql.org/wiki/Audit_trigger_91plus and https://github.com/2ndQuadrant/audit-trigger/ for more information.
Installation
pip install postgres_audit_triggers
Usage
Add the postgres_audit_triggers app to INSTALLED_APPS before any apps that will be audited:
# settings.py INSTALLED_APPS = { 'postgres_audit_triggers', ... }
Run migrations: python manage.py migrate postgres_audit_triggers
Add audit_trigger = True to the Model Meta options of the models that will be audited:
# models.py class MyAuditedModel(models.Model): ... class Meta: audit_trigger = True ...
Make migrations: python manage.py makemigrations
Run migrations: python manage.py migrate
Triggers introduce performance overhead. In certain cases, you may need to disable triggers while performing bulk operations. To turn off all triggers, a decorator is provided:
from postgres_audit_triggers.decorators import disable_triggers @disable_triggers def foo(): # auditing will not be triggered on any database operations performed here Bar.objects.bulk_create(items)
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 Distribution
File details
Details for the file postgres-audit-triggers-0.1.13.tar.gz
.
File metadata
- Download URL: postgres-audit-triggers-0.1.13.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fba785c372095cbc4e5569222f84f63e2b6761845aa8b56c55e9a11f289588b |
|
MD5 | 0690aae79ea565a2a06e850d2b9f6581 |
|
BLAKE2b-256 | 057e7e9fbb1a294283d4e5bb05c9bf75a888f95c48b338376034d62cd067bb28 |