MySQL 8.4+ / MariaDB 10.11+ CDC engine - Python binding (native ctypes)
Project description
mysql-event-stream — Python Binding
A lightweight CDC (Change Data Capture) engine for Python supporting MySQL 8.4+ and MariaDB 10.11+. Parses binlog replication streams and emits structured row-level change events (INSERT / UPDATE / DELETE).
Built on a self-contained C++ core using ctypes FFI for high throughput and low latency. No external MySQL client library (libmysqlclient) required.
Install
pip install mysql-event-stream
Platform wheels are available for:
- Linux x86_64
- Linux aarch64
- macOS ARM64 (Apple Silicon)
Usage
Parsing binlog bytes
from mysql_event_stream import CdcEngine
engine = CdcEngine()
# Feed raw binlog bytes
engine.feed(binlog_chunk)
while (event := engine.next_event()) is not None:
print(event.type, event.database, event.table)
print("before:", event.before)
print("after:", event.after)
Streaming from MySQL
import asyncio
from mysql_event_stream import CdcStream
async def main():
async for event in CdcStream(
host="127.0.0.1",
port=3306,
user="replicator",
password="secret",
):
print(f"{event.type.name} {event.database}.{event.table}")
print(f" before: {event.before}")
print(f" after: {event.after}")
asyncio.run(main())
Event Format
Each ChangeEvent contains the event type, database/table name, binlog position, and row data as a plain dict keyed by column name:
ChangeEvent(
type=EventType.UPDATE,
database="mydb",
table="users",
before={"id": 1, "name": "Alice", "score": 42},
after={"id": 1, "name": "Alice", "score": 100},
timestamp=1773584164,
position=BinlogPosition(file="mysql-bin.000003", offset=3611),
)
Thread Safety
CdcEngine instances are single-owner objects. Do not call feed(),
next_event(), reset(), or filter/configuration methods concurrently on the
same engine instance. Use one engine per thread/task or serialize access
externally.
CdcStream uses an internal reader thread through the native binlog client.
Iteration and connection lifecycle operations should be owned by one task.
Cancellation should go through the stream/client stop path instead of calling
other lifecycle methods concurrently.
Features
- Native performance — C++ core with ctypes FFI, >100k events/sec
- Zero native dependencies — No libmysqlclient required; only OpenSSL
- Streaming — Process events incrementally as bytes arrive
- MySQL 8.4+ — Supports LTS and Innovation releases
- MariaDB 10.11+ — Auto-detects flavor and handles MariaDB binlog protocol (GTID events type 162, ANNOTATE_ROWS, slave capability negotiation)
- GTID support — Native BinlogClient with GTID-based replication (MySQL
uuid:gnoand MariaDBdomain-server-seqformats) - Row-level events — Full before/after column values for INSERT, UPDATE, DELETE
- VECTOR type — Native support for MySQL 9.0+ VECTOR columns (decoded as raw bytes)
- Column names — Automatic column name resolution via metadata queries
- SSL/TLS — Full SSL/TLS support for secure MySQL connections
- Backpressure — Internal reader thread with bounded event queue (default 10,000)
- Auto-reconnection — Automatic reconnection with linear backoff on connection loss
Server Requirements
MySQL:
- Version: 8.4+
- GTID mode enabled (for BinlogClient)
- Replication privileges:
REPLICATION SLAVE,REPLICATION CLIENT
MariaDB:
- Version: 10.11+ (tested against 10.11 and 11.4)
- GTID replication enabled (
log_binin ROW format) - Replication privileges:
REPLICATION SLAVE,REPLICATION CLIENT
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mysql_event_stream-1.3.2-py3-none-manylinux_2_17_x86_64.whl.
File metadata
- Download URL: mysql_event_stream-1.3.2-py3-none-manylinux_2_17_x86_64.whl
- Upload date:
- Size: 2.4 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
048a178a2ef75789589a26770fb58decb6e3bacca5131d1072b2166d4d192773
|
|
| MD5 |
6f31063913a8f3c233a5169c4351d521
|
|
| BLAKE2b-256 |
31df871b88dbd46bfda1db5309411cf25605418b9a52d5c27476aad3dc0ebd11
|
Provenance
The following attestation bundles were made for mysql_event_stream-1.3.2-py3-none-manylinux_2_17_x86_64.whl:
Publisher:
publish.yml on libraz/mysql-event-stream
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mysql_event_stream-1.3.2-py3-none-manylinux_2_17_x86_64.whl -
Subject digest:
048a178a2ef75789589a26770fb58decb6e3bacca5131d1072b2166d4d192773 - Sigstore transparency entry: 1554668414
- Sigstore integration time:
-
Permalink:
libraz/mysql-event-stream@64673bb5e219da0da9227a6b95f76f0f028ed679 -
Branch / Tag:
refs/tags/v1.3.2 - Owner: https://github.com/libraz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@64673bb5e219da0da9227a6b95f76f0f028ed679 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mysql_event_stream-1.3.2-py3-none-manylinux_2_17_aarch64.whl.
File metadata
- Download URL: mysql_event_stream-1.3.2-py3-none-manylinux_2_17_aarch64.whl
- Upload date:
- Size: 2.2 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c656488a844703df7958d9a77efa961d2960c3c96826774b9c8f8314c256f1c
|
|
| MD5 |
f983e5213e37bb4fddf605d57ed5b832
|
|
| BLAKE2b-256 |
defb848119c585598c0468a2388a27531e2367ca4ec8eb8b4743301da3e2f585
|
Provenance
The following attestation bundles were made for mysql_event_stream-1.3.2-py3-none-manylinux_2_17_aarch64.whl:
Publisher:
publish.yml on libraz/mysql-event-stream
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mysql_event_stream-1.3.2-py3-none-manylinux_2_17_aarch64.whl -
Subject digest:
4c656488a844703df7958d9a77efa961d2960c3c96826774b9c8f8314c256f1c - Sigstore transparency entry: 1554668385
- Sigstore integration time:
-
Permalink:
libraz/mysql-event-stream@64673bb5e219da0da9227a6b95f76f0f028ed679 -
Branch / Tag:
refs/tags/v1.3.2 - Owner: https://github.com/libraz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@64673bb5e219da0da9227a6b95f76f0f028ed679 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mysql_event_stream-1.3.2-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: mysql_event_stream-1.3.2-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.6 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ac45a633c972c25e7638843434db64d180340dd2d8ec35592b7f4949b98cc0a
|
|
| MD5 |
6cc8930e7417bec9ad305789b9712c53
|
|
| BLAKE2b-256 |
7aa7e072d7d9a254650d484fa344db5256624f0e0a04395f21b2eee578b89e0f
|
Provenance
The following attestation bundles were made for mysql_event_stream-1.3.2-py3-none-macosx_11_0_arm64.whl:
Publisher:
publish.yml on libraz/mysql-event-stream
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mysql_event_stream-1.3.2-py3-none-macosx_11_0_arm64.whl -
Subject digest:
4ac45a633c972c25e7638843434db64d180340dd2d8ec35592b7f4949b98cc0a - Sigstore transparency entry: 1554668350
- Sigstore integration time:
-
Permalink:
libraz/mysql-event-stream@64673bb5e219da0da9227a6b95f76f0f028ed679 -
Branch / Tag:
refs/tags/v1.3.2 - Owner: https://github.com/libraz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@64673bb5e219da0da9227a6b95f76f0f028ed679 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mysql_event_stream-1.3.2-py3-none-macosx_10_15_x86_64.whl.
File metadata
- Download URL: mysql_event_stream-1.3.2-py3-none-macosx_10_15_x86_64.whl
- Upload date:
- Size: 2.3 MB
- Tags: Python 3, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45f6bf1a496cbc486bd48ac76874792d22fad4677bf5533baf1bcbd9d0fcafe5
|
|
| MD5 |
564bec9e50ce962df37b985cb502808f
|
|
| BLAKE2b-256 |
dc1430be8c5ca6642ddf5ee171e3f866f4dd324f1a2f4587484fbfd6894bb065
|
Provenance
The following attestation bundles were made for mysql_event_stream-1.3.2-py3-none-macosx_10_15_x86_64.whl:
Publisher:
publish.yml on libraz/mysql-event-stream
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mysql_event_stream-1.3.2-py3-none-macosx_10_15_x86_64.whl -
Subject digest:
45f6bf1a496cbc486bd48ac76874792d22fad4677bf5533baf1bcbd9d0fcafe5 - Sigstore transparency entry: 1554668456
- Sigstore integration time:
-
Permalink:
libraz/mysql-event-stream@64673bb5e219da0da9227a6b95f76f0f028ed679 -
Branch / Tag:
refs/tags/v1.3.2 - Owner: https://github.com/libraz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@64673bb5e219da0da9227a6b95f76f0f028ed679 -
Trigger Event:
push
-
Statement type: