PostgreSQL-Audit
Auditing extension for PostgreSQL. Provides additional extensions for SQLAlchemy and Flask. PostgreSQL-Audit tries to combine the best of breed from existing solutions such as SQLAlchemy-Continuum, Papertrail and especially Audit Trigger by 2nd Quadrant.
Compared to existing solutions PostgreSQL-Audit has the following charasteristics:
Stores all versions into single table called ‘activity’
Uses minimalistic trigger based approach to keep INSERTs, UPDATEs and DELETEs as fast as possible
- Tracks actor IDs to be able to answer these questions quickly:
Who modified record x on day x?
What did person x do between y and z?
Can you show me the activity history of record x?
Installation
pip install PostgreSQL-Audit
Running the tests
git clone https://github.com/kvesteri/postgresql-audit.git cd postgresql-audit pip install tox createdb postgresql_audit_test tox
Flask extension
from postgresql_audit.flask import versioning_manager
from my_app.extensions import db
versioning_manager.init(db.Model)
class Article(db.Model):
__tablename__ = 'article'
__versioned__ = {} # <- IMPORTANT!
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String)
article = Article(name='Some article')
db.session.add(article)
db.session.commit()
Now we can check the newly created activity.
Activity = versioning_manager.activity_cls
activity = Activity.query.first()
activity.id # 1
activity.table_name # 'article'
activity.verb # 'insert'
activity.old_data # None
activity.changed_data # {'id': '1', 'name': 'Some article'}
article.name = 'Some other article'
db.session.commit()
activity = Activity.query.order_by(db.desc(Activity.id)).first()
activity.id # 2
activity.table_name # 'article'
activity.verb # 'update'
activity.object_id # 1
activity.old_data # {'id': '1', 'name': 'Some article'}
activity.changed_data # {'name': 'Some other article'}
db.session.delete(article)
db.session.commit()
activity = Activity.query.order_by(db.desc(Activity.id)).first()
activity.id # 3
activity.table_name # 'article'
activity.verb # 'delete'
activity.object_id # 1
activity.old_data # {'id': '1', 'name': 'Some other article'}
activity.changed_data # None
Metadata
Release files for postgresql-audit 0.18.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| postgresql_audit-0.18.0.tar.gz | 28.6 kB | Without provenance | Details for postgresql_audit-0.18.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| postgresql_audit-0.18.0-py3-none-any.whl | Python 3 | none | any | Details for postgresql_audit-0.18.0-py3-none-any.whl |
Total release size: 44.2 kB
Release files / postgresql_audit-0.18.0.tar.gz
| Download URL | postgresql_audit-0.18.0.tar.gz |
|---|---|
| Size | 28.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f3725092df5b7003d3da68b21e57d37f8e15e001d9242108e8c5b8e4fe27ad93
|
|
BLAKE2b-256 checksum How to use checksums |
c6fe9b5c05dc058e7e6d91768343973e788e4784dd1b12b8cca2c302ad8c463d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Release files / postgresql_audit-0.18.0-py3-none-any.whl
| Download URL | postgresql_audit-0.18.0-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ce76d8af1402e336112c6539333c538e25972346d04f624a60dfd5a8163b95b
|
|
BLAKE2b-256 checksum How to use checksums |
9776805845b993f692d6f32a8ca74b13dedfd320aa07f48e973302d0797e87d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Security for postgresql-audit 0.18.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.