mysql-replication
Pure Python Implementation of MySQL replication protocol build on top of PyMYSQL.
What it is and what it does
mysql-replication is a pure Python library that implements the MySQL replication protocol on top of pymysql, allowing you to connect to a MySQL server and stream binary log events in real time. It captures INSERT, UPDATE, and DELETE operations with their full row data and original SQL queries, making it possible to react to database changes as they happen.
The library is designed for building change data capture pipelines—feeding database changes into NoSQL systems, search engines, caches, analytics platforms, or audit logs. It works with MySQL 5.5 through 8.0.14 and MariaDB 10.6, and has been used in production by medium-scale internet companies. Configuration requires enabling binary logging on the MySQL server and setting specific binlog parameters; once set up, the library handles the protocol details transparently.
Use it for:
- Replicate MySQL data to NoSQL databases or data warehouses in near real time.
- Invalidate application caches automatically when rows change in the database, eliminating stale data.
- Stream database changes to event brokers for event-driven architectures and downstream processing.
- Build audit trails and compliance logs by capturing all mutations to sensitive tables.
- Feed real-time analytics systems with fresh data from transactional databases.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Reads MySQL binary logs and streams replication events (inserts, updates, deletes) with their data and raw SQL queries to Python, enabling real-time capture of database changes.
Yes. The package is actively maintained, has low install friction, carries a permissive license, and fills a clear niche in MySQL change capture. It is production-tested and widely adopted for CDC pipelines. Install it if you need to react to MySQL changes in real time; skip it if your use case does not require streaming binary log events or if you are not using MySQL.
Install
mysql-replication on PyPI
pip
pip install mysql-replicationuv
uv add mysql-replicationpoetry
poetry add mysql-replicationInstalling mysql-replication
Before you install
Low friction: pure Python wheel with only two runtime dependencies (packaging and pymysql). Actively maintained with a recent release and 2415 repository stars. Tested against MySQL 5.5–8.0.14 and MariaDB 10.6.
License in practice
Licensed under Apache 2 (permissive), allowing commercial and private use with minimal restrictions—suitable for production deployments and proprietary integrations.
Quickstart
pip install mysql-replication
from pymysqlreplication import BinLogStreamReader
mysql_settings = {'host': '127.0.0.1', 'port': 3306, 'user': 'root', 'passwd': ''}
stream = BinLogStreamReader(connection_settings=mysql_settings, server_id=100)
for binlogevent in stream:
binlogevent.dump()
stream.close()
MySQL server must have binary logging enabled with binlog_format='ROW', and for MySQL 8.0.14+ requires binlog_row_metadata='FULL' and binlog_row_image='FULL'.
Verify before relying
- Whether the library handles all MySQL 8.0 versions beyond 8.0.14 or only that specific release forward.
- Real-world performance characteristics and throughput limits under high-volume replication scenarios.
- Completeness of support for all binary log event types and edge cases in production environments.
- Compatibility with Python versions beyond 3.14 or earlier than 3.10.
Package facts
| License | Apache 2 (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — packaging, pymysql |
| Maintenance | actively maintained — 8 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 453,572/month — #6,576 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mysql_replication-1.0.17-py3-none-any.whl
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
PyMySQLPyMySQL is a pure-Python MySQL and MariaDB…
permissive · top 1,000 on PyPI
asyncmy2asyncmy2 is a fast asyncio-based MySQL/MariaDB…
permissive · top 15,000 on PyPI
pysqlsyncSynchronize database schemas and bulk-load data…
permissive · top 15,000 on PyPI
asyncmyasyncmy is an asyncio-native MySQL/MariaDB…
permissive · top 5,000 on PyPI
pytest-mysqlA pytest plugin that provides MySQL and MariaDB…
copyleft · top 15,000 on PyPI
django-mysqlDjango-MySQL extends Django's ORM with MySQL…
permissive · top 15,000 on PyPI
pangresUpserts pandas DataFrames into PostgreSQL,…
permissive · top 15,000 on PyPI
mo-sql-parsingParses SQL queries into JSON-serializable parse…
copyleft · top 15,000 on PyPI
mysql-connector-pythonMySQL Connector/Python is a PEP 249-compliant…
copyleft · top 1,000 on PyPI