Automatic field-level audit trail for all SQLModel entities
Project description
simple_module_audit_log
Automatic field-level audit trail for all SQLModel entities in simple_module apps. Every create / update / delete / soft-delete is captured in the audit_log_audit_entry table with the changed fields, the user who made the change, and the request correlation id — no instrumentation required in module code.
Install
pip install simple_module_audit_log
Add simple_module_audit_log to your host's dependencies and the entry point will be discovered automatically.
What it provides
- Two-phase capture (
before_flushsnapshots diffs,after_flush_postexecresolves DB-assigned primary keys) so integer-PK entities record the real id, not the empty string. AuditEntrySQLModel table with indexedentity_type,entity_id,user_id,created_atcolumns.GET /api/audit_log/REST endpoint withentity_type,entity_id,action,user_id,from_date,to_date, paging filters./audit_logInertia browse page with the same filter set rendered as a table, gated by theaudit_log.viewpermission.- Opt-outs: set
__audit_exclude__ = Trueon a model to skip it entirely, or__audit_exclude_fields__ = {"password_hash"}to skip specific columns.AuditMixin/SoftDeleteMixinbookkeeping fields are excluded automatically.
Usage
Install the module and grant the audit_log.view permission to your admin role. Audit entries appear automatically for every entity that does not opt out.
To exclude a sensitive column:
from typing import ClassVar
from sqlmodel import Field
from simple_module_db.base import create_module_base
from simple_module_db.mixins import AuditMixin
Base = create_module_base("auth")
class Credential(Base, AuditMixin, table=True):
__audit_exclude_fields__: ClassVar[set[str]] = {"password_hash"}
id: int | None = Field(default=None, primary_key=True)
user_id: str
password_hash: str
To opt a whole table out:
class Cache(Base, table=True):
__audit_exclude__ = True
...
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_module_audit_log-0.0.24.tar.gz.
File metadata
- Download URL: simple_module_audit_log-0.0.24.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d16a23133e1c8a0e84284b8d6d76006aaaa1f555299031877a7a5cec7fb2cc3
|
|
| MD5 |
ec6f55360d5a0eefb63f3a1ed5ec8164
|
|
| BLAKE2b-256 |
391cda9ad7cd9982169fd7d38d91489ddd5aa9ba0925dc05deab5e61064e711e
|
Provenance
The following attestation bundles were made for simple_module_audit_log-0.0.24.tar.gz:
Publisher:
release.yml on antosubash/simple_module_python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simple_module_audit_log-0.0.24.tar.gz -
Subject digest:
4d16a23133e1c8a0e84284b8d6d76006aaaa1f555299031877a7a5cec7fb2cc3 - Sigstore transparency entry: 2026387940
- Sigstore integration time:
-
Permalink:
antosubash/simple_module_python@35bb8df75943c017d7a7d581859027157488f1d9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/antosubash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@35bb8df75943c017d7a7d581859027157488f1d9 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file simple_module_audit_log-0.0.24-py3-none-any.whl.
File metadata
- Download URL: simple_module_audit_log-0.0.24-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94a598456d72971d41df77923ae9a8954c1dc9393d199b425f0af078ec334593
|
|
| MD5 |
8e7542d29a58ee73aa6e11cedccaeb6b
|
|
| BLAKE2b-256 |
9ee93457d4b445f795ee00fd64321eca114b1b1445157d8ee095675ef193ed04
|
Provenance
The following attestation bundles were made for simple_module_audit_log-0.0.24-py3-none-any.whl:
Publisher:
release.yml on antosubash/simple_module_python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simple_module_audit_log-0.0.24-py3-none-any.whl -
Subject digest:
94a598456d72971d41df77923ae9a8954c1dc9393d199b425f0af078ec334593 - Sigstore transparency entry: 2026388052
- Sigstore integration time:
-
Permalink:
antosubash/simple_module_python@35bb8df75943c017d7a7d581859027157488f1d9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/antosubash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@35bb8df75943c017d7a7d581859027157488f1d9 -
Trigger Event:
workflow_dispatch
-
Statement type: