Python binlog basic listener and hard delete
email alert using smtplib
. It is created by using python-mysql-replication package.
Based on python-mysql-replication package, you might need to run this with pypy
for better performance & optimization.
- Install required package.
pypy -m pip install -r requirements.txt
- You might need to install mysql connector
- adjust your environment in
.env
, you can copy from.env.example
- adjust event & alert configuration
listener.json
- run
pypy main.py
key | description |
---|---|
only_schemas |
List of string of schema/database you want to listen. The default is true which means all schema of current user |
ignored_schemas |
List of string of schema/database you want to ignore. The default is null which means you do not ignore any database. |
only_tables |
List of string of table you want to listen. The default is true which means all table of database(s). |
ignored_tables |
List of string of table you want to ignore. The default is null which means you do not ignore any table |
only_events |
List of event you want to listen. The default value is true which means you want to listen all available events. Available value: deleterows , writerows , updaterows , tablemap , query . |
ignore_events |
List of event you want to ignore. The default value is null which means you do not ignore any event. Available value: deleterows , writerows , updaterows , tablemap , query . |
recipient |
List of email that you want to send deleterows notification |
cc |
List of email that you want to send deleterows notification as cc |
bcc |
List of email that you want to send deleterows notification as bcc |
save_last_delete |
Save your last delete event's timestamp. It is used to skip any binlog event until your last run timestamp.. Example: Last run is C -> kill the program -> rerun the program -> the app will skip dumping the events until its timestamp >= C . |
- python 3.10
- pypy3.9
- mysql 8.0 (docker)
- windows