Skip to main content

AUDIT FOR SQLAlchemy and Mongoengine

Library for auditing models made with SQLAlchemy and Mongoengine. This library exposes a signal which you can use to add your custom method.

Instalation

Use following command:

pip install package-audit-flask

Usage

This library exposes a signal which you can use to add your custom method, this method receives kwargs where predefined arguments will arrive.

How is it used in SQLAlchemy?

Import library and then "Register" your model using the keep_logs_models method, as follows:"

from fk_audit_flask.audit.sqlalchemy import sqlalchemy

class Model:
    ...

sqlalchemy.keep_logs_models(Model)

Then, conect the "signal" signal with your custom method

def custom_method(*args, **kwargs):
    ...

sqlalchemy.signal.connect(custom_method)

Kwargs in your custom method

If SETTINGS.HEADERS = FALSE

Name Type Desciption
object_pk int Primary key
content_type str Name of the table or collection
object_repr dict Object in dictionary after changes
action str It can be any of the following options ['create', 'delete', 'update']
changes str Object changes
object_before_changed dict Object in dictionary before changes

If SETTINGS.HEADERS = True

Same as above, with two additional keys.

Name Type Desciption
remote_addr dict Corresponds to the headers of the request made
user str Dictionary with the keys assigned in SETTINGS.USER_VALIDATE_HEADERS

Additional configuration

  • If you have a key that you need to extract for the user kwargs, add the keys in the SETTINGS.USER_VALIDATE_HEADERS configuration by default you have assigned: ['X-User-Id', 'X-Auth-User-Id'].
  • If you do not want to get the kwargs remote_addr and user, asgine SETTINGS.HEADERS = False

Dependencies

  • flask>=2.2.5 # If SETTINGS.HEADERS = True, deafult is True
  • blinker>=1.4
  • mongoengine>=0.23.1
  • sqlalchemy>=1.4.52

License

MIT

Authors

Release files for package-audit-flask 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for package-audit-flask 0.1.6
File Size Uploaded
package_audit_flask-0.1.6.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for package-audit-flask 0.1.6
File Interpreter ABI Platform
package_audit_flask-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 13.9 kB

Release files / package_audit_flask-0.1.6.tar.gz

Download URL package_audit_flask-0.1.6.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
501e5d1cf5bf838157da3fb0706a157641564989c3452f72a33aa595e31573b9
BLAKE2b-256 checksum
How to use checksums
1dfb188bb74f21e834996ff33cab92d7c800b4cf8f161b5231c7b15bb44278d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.13.14 Linux/6.17.0-1020-azure

Release files / package_audit_flask-0.1.6-py3-none-any.whl

Download URL package_audit_flask-0.1.6-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ffa2f017a14eb1ce2f948ecbfa154f5069ed095bc6be0b5f5569c703a98de02
BLAKE2b-256 checksum
How to use checksums
be6ddc249d89d29e4576ed4c9819fed56384899f1d476218896321e760afc840
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.13.14 Linux/6.17.0-1020-azure

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release 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