flask-postgresql-audit 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of flask-postgresql-audit might be problematic. Click here for more details.

Files changed (36) hide show
  1. flask_postgresql_audit-1.0.0/.gitignore +65 -0
  2. flask_postgresql_audit-1.0.0/CHANGES.md +271 -0
  3. flask_postgresql_audit-1.0.0/LICENSE +25 -0
  4. flask_postgresql_audit-1.0.0/PKG-INFO +194 -0
  5. flask_postgresql_audit-1.0.0/README.md +167 -0
  6. flask_postgresql_audit-1.0.0/flask_postgresql_audit/__init__.py +4 -0
  7. flask_postgresql_audit-1.0.0/flask_postgresql_audit/alembic/__init__.py +2 -0
  8. flask_postgresql_audit-1.0.0/flask_postgresql_audit/alembic/entities.py +64 -0
  9. flask_postgresql_audit-1.0.0/flask_postgresql_audit/alembic/schema.py +58 -0
  10. flask_postgresql_audit-1.0.0/flask_postgresql_audit/alembic/setup.py +93 -0
  11. flask_postgresql_audit-1.0.0/flask_postgresql_audit/base.py +51 -0
  12. flask_postgresql_audit-1.0.0/flask_postgresql_audit/core.py +233 -0
  13. flask_postgresql_audit-1.0.0/flask_postgresql_audit/models.py +80 -0
  14. flask_postgresql_audit-1.0.0/flask_postgresql_audit/templates/audit_trigger_delete.sql +6 -0
  15. flask_postgresql_audit-1.0.0/flask_postgresql_audit/templates/audit_trigger_insert.sql +6 -0
  16. flask_postgresql_audit-1.0.0/flask_postgresql_audit/templates/audit_trigger_update.sql +7 -0
  17. flask_postgresql_audit-1.0.0/flask_postgresql_audit/templates/create_activity.sql +86 -0
  18. flask_postgresql_audit-1.0.0/flask_postgresql_audit/templates/create_schema.sql +2 -0
  19. flask_postgresql_audit-1.0.0/flask_postgresql_audit/templates/drop_schema.sql +1 -0
  20. flask_postgresql_audit-1.0.0/flask_postgresql_audit/templates/get_setting.sql +6 -0
  21. flask_postgresql_audit-1.0.0/flask_postgresql_audit/templates/jsonb_subtract.sql +5 -0
  22. flask_postgresql_audit-1.0.0/flask_postgresql_audit/templates/row_audit_trigger.sql +4 -0
  23. flask_postgresql_audit-1.0.0/flask_postgresql_audit/templates/row_create_activity.sql +48 -0
  24. flask_postgresql_audit-1.0.0/flask_postgresql_audit/typing.py +9 -0
  25. flask_postgresql_audit-1.0.0/flask_postgresql_audit/utils.py +30 -0
  26. flask_postgresql_audit-1.0.0/pyproject.toml +57 -0
  27. flask_postgresql_audit-1.0.0/tests/__init__.py +0 -0
  28. flask_postgresql_audit-1.0.0/tests/app.py +59 -0
  29. flask_postgresql_audit-1.0.0/tests/conftest.py +40 -0
  30. flask_postgresql_audit-1.0.0/tests/migrations/README +1 -0
  31. flask_postgresql_audit-1.0.0/tests/migrations/alembic.ini +157 -0
  32. flask_postgresql_audit-1.0.0/tests/migrations/env.py +64 -0
  33. flask_postgresql_audit-1.0.0/tests/migrations/script.py.mako +28 -0
  34. flask_postgresql_audit-1.0.0/tests/test_defaults.py +52 -0
  35. flask_postgresql_audit-1.0.0/tests/test_operators.py +31 -0
  36. flask_postgresql_audit-1.0.0/tests/utils.py +86 -0
@@ -0,0 +1,65 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+
5
+ # C extensions
6
+ *.so
7
+
8
+ # Distribution / packaging
9
+ .eggs/
10
+ .Python
11
+ env/
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ *.egg-info/
23
+ .installed.cfg
24
+ *.egg
25
+
26
+ # PyInstaller
27
+ # Usually these files are written by a python script from a template
28
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
29
+ *.manifest
30
+ *.spec
31
+
32
+ # Installer logs
33
+ pip-log.txt
34
+ pip-delete-this-directory.txt
35
+
36
+ # Unit test / coverage reports
37
+ htmlcov/
38
+ .tox/
39
+ .coverage
40
+ .cache
41
+ nosetests.xml
42
+ coverage.xml
43
+
44
+ # Translations
45
+ *.mo
46
+ *.pot
47
+
48
+ # Django stuff:
49
+ *.log
50
+
51
+ # Sphinx documentation
52
+ docs/_build/
53
+
54
+ # PyBuilder
55
+ target/
56
+
57
+ # SublimeText
58
+ *.sublime-*
59
+
60
+ # UV
61
+ .venv
62
+ uv.lock
63
+
64
+ # VSCode
65
+ .vscode
@@ -0,0 +1,271 @@
1
+ # Changelog
2
+
3
+ Here you can see the full list of changes between each Flask-PostgreSQL-Audit
4
+ release.
5
+
6
+ ## 1.0.0 (2025-10-30)
7
+
8
+ - Forked from PostgreSQL-Audit.
9
+ - Rename `VersioningManager` to `PostgreSQLAudit`.
10
+ - Drop `__versioned__` attribute pattern in favor of `Audit` mixin class.
11
+ - Use `alembic` to make database objects required by pg_audit stateful.
12
+ - Utilize `alembic_utils` to generate migration operations.
13
+ - Blindly create newly generated database object
14
+ to circumvent `alembic_utils` known issue when
15
+ object depends on another object in same migration, issue: [#41](https://github.com/olirice/alembic_utils/issues/41).
16
+ - Update README and LICENSE.
17
+
18
+ ## 0.17.1 (2023-11-06)
19
+
20
+ - Fix package name to be in lowercase in `pyproject.toml`.
21
+
22
+ ## 0.17.0 (2023-11-04)
23
+
24
+ - Use the `pyproject.toml` standard to specify project metadata,
25
+ dependencies and tool configuration. Use Hatch to build the project.
26
+ - Make the documentation buildable again.
27
+ - Fix some grammar and formatting issues in the documentation
28
+ - Refactor `VersioningManager.audit_table()` method and extract the
29
+ query building logic into a new method
30
+ `VersioningManager.build_audit_table_query()`.
31
+ - Fix a deprecation warning about `sqlalchemy.orm.mapper()` symbol
32
+ usage on SQLAlchemy 2.0.
33
+
34
+ ## 0.16.0 (2023-08-04)
35
+
36
+ - **BREAKING CHANGE**: Drop support for PostgreSQL 9.5, 9.6 and 10,
37
+ which have reached end of their lives.
38
+ - Add support for SQLAlchemy 2.0
39
+ - Remove unused `VersioningManager.cached_ddls` attribute
40
+ - Removed redundant statement caching from
41
+ `VersioningManager.audit_table`
42
+
43
+ ## 0.15.0 (2023-05-15)
44
+
45
+ - **BREAKING CHANGE**: `flask.activity_values` doesn\'t require
46
+ request context (#75, courtesy of tvuotila)
47
+ - **BREAKING CHANGE**: Drop support for Python 3.7
48
+ - Fix some SQLAlchemy 2.0 deprecation warnings (#76, courtesy of
49
+ tchapi)
50
+ - Remove unnecessary checks for Flask request context
51
+ - Remove unnecessary `__future__` import
52
+
53
+ ## 0.14.1 (2023-04-26)
54
+
55
+ - Fix compatibility with Flask-SQLAlchemy\<3.0
56
+
57
+ ## 0.14.0 (2023-04-26)
58
+
59
+ - **BREAKING CHANGE**: Drop support for Python 3.6, which reached the
60
+ end of its life on December 23rd, 2021.
61
+ - **BREAKING CHANGE**: Drop support for SQLAlchemy 1.1, 1.2 and 1.3,
62
+ which are no longer maintained.
63
+ - Fix `SAWarning` from SQLAlchemy 1.4 about missing `inherit_cache`
64
+ attribute
65
+ - Fix deprecation warnings from Flask 2.2 about `_app_ctx_stack.top`
66
+ and `_request_ctx_stack.top` usage.
67
+ - Add support for Flask-SQLAlchemy 3.0
68
+ - Add support for Python 3.10 and 3.11
69
+
70
+ ## 0.13.0 (2021-05-16)
71
+
72
+ - Add SQLAlchemy 1.4 support
73
+ - Add Python 3.9 support
74
+ - **BREAKING CHANGE**: Drop Python 2.7 and 3.5 support. Python 2.7
75
+ reached the end of its life on January 1st, 2020 and Python 3.5 on
76
+ September 13th, 2020.
77
+
78
+ ## 0.12.4 (2020-02-18)
79
+
80
+ - Specify the column names when inserting new audit rows (#49,
81
+ courtesy of quantus)
82
+
83
+ ## 0.12.3 (2020-01-16)
84
+
85
+ - Added nesting of activity values (#48, courtesy of tvuotila)
86
+
87
+ ## 0.12.2 (2019-11-12)
88
+
89
+ - Made disable context manager use a finally block (#42, courtesy of
90
+ ElPicador)
91
+
92
+ ## 0.12.1 (2019-10-18)
93
+
94
+ - Added commits missing from 0.12.0
95
+
96
+ ## 0.12.0 (2019-10-15)
97
+
98
+ - Create only single transaction per database transaction (#37)
99
+
100
+ ## 0.11.1 (2019-03-20)
101
+
102
+ - Fixed `postgresql_audit.enable_versioning` parameter to work in
103
+ situations where the transaction is rolled back and this parameter
104
+ is set by the rollback operation as an empty string.
105
+
106
+ ## 0.11.0 (2019-03-10)
107
+
108
+ - Changed the use of `session_replication_role` to
109
+ `postgresql_audit.enable_versioning` parameter. This change was made
110
+ in order to allow temporarly disable versioning in environments such
111
+ as Heroku where changing `session_replication_role` configuration
112
+ setting even on transaction level is impossible. (#31)
113
+ - Drop and create `jsonb_substract` function instead of replacing it
114
+ (#29, courtesy of AdamSelene)
115
+
116
+ ## 0.10.0 (2018-07-20)
117
+
118
+ - Added support for PostgreSQL 10 statement level trigger transition
119
+ tables. Huge performance boost for heavy inserts.
120
+
121
+ ## 0.9.3 (2018-05-13)
122
+
123
+ - Force timestamps to use UTC as timezone (#30, courtesy of quantus)
124
+ - Dropped Python 3.3 support
125
+
126
+ ## 0.9.2 (2017-12-13)
127
+
128
+ - Added PostgreSQL 10 support
129
+
130
+ ## 0.9.1 (2017-10-10)
131
+
132
+ - Fixed `jsonb_subtract` (jsonb - jsonb) support for arrays as values
133
+
134
+ ## 0.9.0 (2017-09-06)
135
+
136
+ - Added different PostgreSQL versions (9.4, 9.5 and 9.6) to test
137
+ matrix
138
+ - Defined activity `old_data` and `changed_data` defaults as empty
139
+ JSONBs
140
+ - Made `Activity.data` use new 9.6 JSONB `concat` operator. On
141
+ PostgreSQL 9.5 and 9.4 this still uses fallback function.
142
+
143
+ ## 0.8.4 (2016-03-27)
144
+
145
+ - Allowed passing `transaction_cls` parameter to `activity_base`
146
+ function (#23, pull request courtesy jmagnusson)
147
+
148
+ ## 0.8.3 (2016-08-20)
149
+
150
+ - Fixed Flask ExtDeprecationWarnings (#17, courtesy of jpvanhal)
151
+
152
+ ## 0.8.2 (2016-08-20)
153
+
154
+ - Added a workaround for SQLAlchemy issue #3778
155
+
156
+ ## 0.8.1 (2016-08-20)
157
+
158
+ - Fixed `modified_columns` method to work with synonym properties
159
+
160
+ ## 0.8.0 (2016-08-03)
161
+
162
+ - Added `transaction` table
163
+ - Moved `actor_id` and `client_addr` columns to `transaction` table
164
+
165
+ ## 0.7.0 (2016-03-06)
166
+
167
+ - Added support for PostgreSQL 9.5. Certain JSONB subtraction
168
+ operators are only created if used PostgreSQL version is below 9.5.
169
+ - Added `rename_table` migration function
170
+
171
+ ## 0.6.0 (2016-01-13)
172
+
173
+ - Added support for activity schema configuration (#4, courtesy of
174
+ jmagnusson)
175
+
176
+ ## 0.5.2 (2016-01-09)
177
+
178
+ - Avoid empty string INET value with Flask `VersioningManager` (#10,
179
+ courtesy of asfaltboy)
180
+
181
+ ## 0.5.1 (2015-04-14)
182
+
183
+ - Fixed migration helpers to work with alembic operations object
184
+
185
+ ## 0.5.0 (2015-04-13)
186
+
187
+ - Added `alter_column` migration helper function
188
+ - Added `change_column_name` migration helper function
189
+ - Added flake8 checks
190
+ - Added isort checks
191
+ - Added `jsonb_change_key_name` function expression
192
+ - Added `jsonb` substraction operator to support text data type
193
+ - Added `remove_column` migration helper
194
+
195
+ ## 0.4.2 (2015-03-13)
196
+
197
+ - Added `data` `hybrid_property` for `Activity` model. This property
198
+ makes it easy to find all changes made in given record.
199
+
200
+ ## 0.4.1 (2015-03-13)
201
+
202
+ - Made `client_addr` overridable
203
+ - Removed `client_port` column from `activity` table (doesn\'t make
204
+ sense in web environment)
205
+
206
+ ## 0.4.0 (2015-03-12)
207
+
208
+ - Added default value for `audit_table` exclude parameter
209
+ - Changed `row_data` and `changed_fields` types from HSTORE to JSONB
210
+ - Removed `object_id` column from `activity` table
211
+ - Renamed `row_data` to `old_data` and `changed_fields` to
212
+ `changed_data`
213
+
214
+ ## 0.3.0 (2015-02-24)
215
+
216
+ - Added Flask extension
217
+ - Rewrote activity values setting. Now values are set after the flush
218
+ phase occurs.
219
+
220
+ ## 0.2.3 (2015-02-21)
221
+
222
+ - Added explicit committing of `audit_table` ddl statements
223
+
224
+ ## 0.2.2 (2015-02-21)
225
+
226
+ - Made `actor_id` and `actor` properties of `Activity` model
227
+ configured during mapper configuration phase
228
+
229
+ ## 0.2.1 (2015-02-20)
230
+
231
+ - Added `audit_table` function
232
+
233
+ ## 0.2.0 (2015-02-19)
234
+
235
+ - Added `__versioned__` configuration parameter for models
236
+ - Added customizable column exclusion support for versioned models
237
+
238
+ ## 0.1.7 (2015-02-18)
239
+
240
+ - Removed foreign key from `actor_id` in `Activity` model
241
+
242
+ ## 0.1.6 (2015-02-18)
243
+
244
+ - Added support for callables as activity values
245
+ - Changed composite primary key separator from \',\' to \'\|\'
246
+
247
+ ## 0.1.5 (2015-02-18)
248
+
249
+ - Fixed pypi setup
250
+
251
+ ## 0.1.4 (2015-02-18)
252
+
253
+ - Made `actor` class and `actor_id` column customizable
254
+
255
+ ## 0.1.3 (2015-02-17)
256
+
257
+ - Made all file reads use absolute paths
258
+
259
+ ## 0.1.2 (2015-02-17)
260
+
261
+ - Removed all default indexes from activity table
262
+
263
+ ## 0.1.1 (2015-02-17)
264
+
265
+ - Added `__repr__` for activity classes
266
+ - Removed session user name column from activity table
267
+ - Removed application name column from activity table
268
+
269
+ ## 0.1 (2015-02-17)
270
+
271
+ - Initial public release
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2015, Konsta Vesterinen
2
+ Copyright (c) 2025, Higamigu
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ * Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ * Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+
@@ -0,0 +1,194 @@
1
+ Metadata-Version: 2.4
2
+ Name: flask-postgresql_audit
3
+ Version: 1.0.0
4
+ Summary: Versioning and auditing extension for PostgreSQL and SQLAlchemy.
5
+ Project-URL: Homepage, https://github.com/higamigu/flask-postgresql-audit
6
+ Author-email: Konsta Vesterinen <konsta@fastmonkeys.com>, Refian Muhammad <higamigu@gmail.com>
7
+ License-Expression: BSD-2-Clause
8
+ License-File: LICENSE
9
+ Classifier: Environment :: Web Environment
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: BSD License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Python: >=3.11
21
+ Requires-Dist: alembic-utils>=0.8.8
22
+ Requires-Dist: alembic>=1.17.0
23
+ Requires-Dist: flask-sqlalchemy>=3.1.1
24
+ Requires-Dist: flask>=3.1.2
25
+ Requires-Dist: psycopg2>=2.9.11
26
+ Description-Content-Type: text/markdown
27
+
28
+ # Flask-PostgreSQL-Audit
29
+
30
+ ![BuildStatus](https://github.com/higamigu/flask-postgresql-audit/actions/workflows/test.yml/badge.svg?branch=main)
31
+ [![VersionStatus](https://img.shields.io/pypi/v/PostgreSQL-Audit.svg)](https://pypi.python.org/pypi/PostgreSQL-Audit/)
32
+ [![Downloads](https://img.shields.io/pypi/dm/PostgreSQL-Audit.svg)](https://pypi.python.org/pypi/PostgreSQL-Audit/)
33
+
34
+ Auditing extension for Flask-SQLAlchemy with PostgreSQL.
35
+ Forked from [PostgreSQL-Audit](https://github.com/kvesteri/postgresql-audit), tries to combine the best of breed from existing solutions such as
36
+ [SQLAlchemy-Continuum](https://github.com/kvesteri/SQLAlchemy-Continuum),
37
+ [Papertrail](https://github.com/airblade/paper_trail) and especially
38
+ [Audit Trigger by 2ndQuadrant](https://github.com/2ndQuadrant/audit-trigger).
39
+
40
+ - Stores audit recordss into single table called \'pga_activity\'
41
+ - Uses stateful trigger based approach to keep INSERTs, UPDATEs
42
+ and DELETEs as fast as possible
43
+ - Tracks and stores actor identities into table called \'pga_transaction\'
44
+ - Uses Alembic and Alembic-Utils to generate necessary database objects
45
+
46
+ ## Installation
47
+ ```
48
+ uv add
49
+ ```
50
+ or install directly from this repo
51
+ ```
52
+ uv add git+https://github.com/higamigu/flask-postgresql-audit --tag v1.0.0
53
+ ```
54
+
55
+ ## Usage
56
+
57
+ ``` python
58
+ from flask_sqlalchemy import SQLAlchemy
59
+ from flask_postgresql_audit import PostgreSQLAudit, Audit
60
+
61
+ from my_app import app # your flask app
62
+
63
+ db = SQLAlchemy()
64
+ audit = PostgreSQLAudit()
65
+
66
+ class Article(db.Model, Audit):
67
+ __tablename__ = 'article'
68
+
69
+ id = db.Column(db.Integer, primary_key=True)
70
+ name = db.Column(db.String)
71
+
72
+ db.init_app(app)
73
+ audit.init_app(app, db)
74
+
75
+ article = Article(name='Some article')
76
+ db.session.add(article)
77
+ db.session.commit()
78
+ ```
79
+ Then generate migration file
80
+ ```
81
+ flask db migrate -m "pg audit initial migration"
82
+ flask db upgrade
83
+ ```
84
+
85
+ Now we can check the newly created activity.
86
+
87
+ ``` python
88
+ activity = db.session.scalar(select(audit.Activity))
89
+ activity.id # 1
90
+ activity.table_name # 'article'
91
+ activity.verb # 'insert'
92
+ activity.old_data # None
93
+ activity.changed_data # {'id': '1', 'name': 'Some article'}
94
+ ```
95
+
96
+ ``` python
97
+ article.name = 'Some other article'
98
+ db.session.commit()
99
+
100
+ activity = db.session.scalar(select(audit.Activity).order_by(desc("id")))
101
+ activity.id # 2
102
+ activity.table_name # 'article'
103
+ activity.verb # 'update'
104
+ activity.object_id # 1
105
+ activity.old_data # {'id': '1', 'name': 'Some article'}
106
+ activity.changed_data # {'name': 'Some other article'}
107
+ ```
108
+
109
+ ``` python
110
+ db.session.delete(article)
111
+ db.session.commit()
112
+
113
+ activity = db.session.scalar(select(audit.Activity).order_by(desc("id")))
114
+ activity.id # 3
115
+ activity.table_name # 'article'
116
+ activity.verb # 'delete'
117
+ activity.object_id # 1
118
+ activity.old_data # {'id': '1', 'name': 'Some other article'}
119
+ activity.changed_data # None
120
+ ```
121
+
122
+ ## Different Schema
123
+ You can isolate `pg_audit` objects entirely to a different schema by doing
124
+
125
+ ``` python
126
+ from flask_postgresql_audit import PostgreSQLAudit
127
+
128
+ audit = PostgreSQLAudit(schema="audit")
129
+
130
+ ...
131
+ ```
132
+ And then you need to tell alembic to track other than `public` schema by adding following line in `alembic/env.py`
133
+ ``` python
134
+ ...
135
+
136
+ def run_migrations_online():
137
+ connectable = get_engine()
138
+
139
+ with connectable.connect() as connection:
140
+ context.configure(
141
+ connection=connection,
142
+ target_metadata=get_metadata(),
143
+ include_schemas=True, # add this arg
144
+ ...
145
+ )
146
+
147
+ with context.begin_transaction():
148
+ context.run_migrations()
149
+
150
+ ...
151
+ ```
152
+
153
+ ## Custom Actor ID getter
154
+ You can customize actor id getter function by doing the following. Here is an example using `current_user` from `flask_jwt_extended` library.
155
+
156
+ ``` python
157
+ from flask_jwt_extended import jwt_required, current_user
158
+
159
+ @jwt_required(optional=True)
160
+ def actor_id_getter():
161
+ try:
162
+ return current_user.email or None
163
+ except Exception:
164
+ return None
165
+
166
+ ...
167
+
168
+ audit = PostgreSQLAudit(actor_id_getter=actor_id_getter)
169
+
170
+ ...
171
+ ```
172
+
173
+ ## Enable Alembic Logger
174
+ You can enable alembic logger for `pg_audit` by adding the following to your `alembic.ini`
175
+ ``` ini
176
+ # Logging configuration
177
+ [loggers]
178
+ keys = root,sqlalchemy,alembic,alembic_utils,pg_audit # add 'pg_audit' here
179
+
180
+ ...
181
+
182
+ [logger_pg_audit] # and add the logger for pg_audit here
183
+ level = INFO
184
+ handlers =
185
+ qualname = pg_audit
186
+ ```
187
+
188
+ ## Running the tests
189
+
190
+ git clone https://github.com/higamigu/flask-postgresql-audit.git
191
+ cd flask-postgresql-audit
192
+ pip install tox
193
+ createdb postgresql_audit_test
194
+ tox