skillfed

mysql-replication

Pure Python Implementation of MySQL replication protocol build on top of PyMYSQL.

mysql-replication v1.0.17 453.6K downloads/30d#6,576 on PyPI2,415
Permissive license Apache 2 Active released

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-replication

uv

uv add mysql-replication

poetry

poetry add mysql-replication

Installing 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

mysql binary log readermysql change data capturemysql replication protocol pythonmysql binlog streamingmysql cdc eventsdatabase change capturemysql event replication
change-data-capturemysql-binlogreplication

More Database packages