django-myql-migration
MySQL DB change events by reading replication logs. These are useful when the data is directly inserted into the MySQL database.
Installation
Install via pip
pip install django-myql-migration
Add "django_myql_migration" to your INSTALLED_APPS settings like this:
INSTALLED_APPS = (
"django_myql_migration",
...
)
Edit my.cnf to setup replication, as follows:
[mysqld]
log-bin=mysql-bin
server-id=1
binlog-format=row
gtid_mode=ON
log-slave_updates=true
enforce_gtid_consistency
binlog-row-metadata=FULL
binlog-row-image=FULL
Set these environment variables MYSQL_HOST, MYSQL_PORT, MYSQL_DATABASE, MYSQL_SLAVE_USER, MYSQL_SLAVE_PASSWORD
Add replication user using the following command
mysql -u root -p -h ${MYSQL_HOST} -P ${MYSQL_PORT} ${MYSQL_DATABASE} -e "CREATE USER '${MYSQL_SLAVE_USER}'@'%' IDENTIFIED BY '${MYSQL_SLAVE_PASSWORD}'; GRANT REPLICATION SLAVE, REPLICATION CLIENT, SELECT ON *.* TO '${MYSQL_SLAVE_USER}'@'%';FLUSH PRIVILEGES;"
Usage
There are 3 signals generated by the package: row_inserted, row_deleted and row_updated. You can use the standard Django signal handling mechanism to handle signals. e.g. To know when the user is added to the system, you can create a signals.py file with the following content
from django_mysql_replication.signals import row_inserted
from django.contrib.auth import get_user_model
User = get_user_model()
@receiver(row_inserted, sender=User)
def user_added(sender, instance, *args, **kwargs):
pass
Run the following command to listen to DB changes
python manage.py listen
Metadata
Release files for django-mysql-replication 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-mysql-replication-0.1.3.tar.gz | 5.8 kB | Without provenance | Details for django-mysql-replication-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_mysql_replication-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for django_mysql_replication-0.1.3-py3-none-any.whl |
Total release size: 12.7 kB
Release files / django-mysql-replication-0.1.3.tar.gz
| Download URL | django-mysql-replication-0.1.3.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc8ffb2f8366ff98f3a7dff2c92de86e499b1087a7f6cdd63d9833f5b2e1d892
|
|
BLAKE2b-256 checksum How to use checksums |
c82301f2a63b23ed9d64318e07c187a58972a65895b7c0db353be493e554e792
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Release files / django_mysql_replication-0.1.3-py3-none-any.whl
| Download URL | django_mysql_replication-0.1.3-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9da32b926705c1b85ccaac49812a3b10ddb63334336b7342de187bcd2e8228ed
|
|
BLAKE2b-256 checksum How to use checksums |
60f1dd490d55281407908ef3933470343c1b37ac94daec5f39727a834343c7d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Security for django-mysql-replication 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.