Skip to main content

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_flush snapshots diffs, after_flush_postexec resolves DB-assigned primary keys) so integer-PK entities record the real id, not the empty string.
  • AuditEntry SQLModel table with indexed entity_type, entity_id, user_id, created_at columns.
  • GET /api/audit_log/ REST endpoint with entity_type, entity_id, action, user_id, from_date, to_date, paging filters.
  • /audit_log Inertia browse page with the same filter set rendered as a table, gated by the audit_log.view permission.
  • Opt-outs: set __audit_exclude__ = True on a model to skip it entirely, or __audit_exclude_fields__ = {"password_hash"} to skip specific columns. AuditMixin / SoftDeleteMixin bookkeeping 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_module_audit_log-0.0.27.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_module_audit_log-0.0.27-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file simple_module_audit_log-0.0.27.tar.gz.

File metadata

  • Download URL: simple_module_audit_log-0.0.27.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for simple_module_audit_log-0.0.27.tar.gz
Algorithm Hash digest
SHA256 9d9c01e488b2b054d12c2954aa401d7a8460ebc6b0b44076415b22c16faedeb5
MD5 f33d2f048c0c036d0428ed1ad1d8a856
BLAKE2b-256 9f0acf9f8a44d1785d73bfcc6a7b8244e4ec8b9d508b3eb5ab4f4309a7de2943

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_audit_log-0.0.27.tar.gz:

Publisher: release.yml on antosubash/simple_module_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simple_module_audit_log-0.0.27-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_module_audit_log-0.0.27-py3-none-any.whl
Algorithm Hash digest
SHA256 4f55a4edbf6cd88c513502df7bde2a4a9baa29bbf0c69dc07e48b32f79dcf9c0
MD5 446c29097df8d80da2044fac37091b39
BLAKE2b-256 917fab85b96fbd1bc33814ca9be5d8138a1581487b1598c701894b25d27a58ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_audit_log-0.0.27-py3-none-any.whl:

Publisher: release.yml on antosubash/simple_module_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.0.33

2 files

0.0.32

2 files

0.0.31

2 files

0.0.30

2 files

0.0.29

2 files

0.0.28

2 files

This release

0.0.27 This release

2 files

0.0.26

2 files

0.0.25

2 files

0.0.24

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page