MySQL 8.4 CDC engine - Python binding (native ctypes)
Project description
mysql-event-stream — Python Binding
A lightweight MySQL 8.4 CDC (Change Data Capture) engine for Python. 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),
)
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 — Built for the latest MySQL LTS release
- GTID support — Native BinlogClient with GTID-based replication
- Row-level events — Full before/after column values for INSERT, UPDATE, DELETE
- 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
MySQL Requirements
- Version: 8.4
- Binary log format: ROW (
binlog_format=ROW) - GTID mode enabled (for BinlogClient)
- 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.0.1-py3-none-manylinux_2_17_x86_64.whl.
File metadata
- Download URL: mysql_event_stream-1.0.1-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.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2930df0aefeecef24958a1a05eae0652868be48323e2dbd8d1aecc194007eede
|
|
| MD5 |
fd644579510246d5295bea96819b105f
|
|
| BLAKE2b-256 |
ad0e5ed274e5f1809a4546497a6e25d2676cc7a250897105ef7295cb5db2084c
|
Provenance
The following attestation bundles were made for mysql_event_stream-1.0.1-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.0.1-py3-none-manylinux_2_17_x86_64.whl -
Subject digest:
2930df0aefeecef24958a1a05eae0652868be48323e2dbd8d1aecc194007eede - Sigstore transparency entry: 1186444197
- Sigstore integration time:
-
Permalink:
libraz/mysql-event-stream@0434ea80d0ef833684d03d92183626773e935ead -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/libraz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0434ea80d0ef833684d03d92183626773e935ead -
Trigger Event:
push
-
Statement type:
File details
Details for the file mysql_event_stream-1.0.1-py3-none-manylinux_2_17_aarch64.whl.
File metadata
- Download URL: mysql_event_stream-1.0.1-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.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1274a592d0b08e3cd06ab877f3d07f04ab23bc0095747afa7dd300f904c75309
|
|
| MD5 |
aae2dfb47a887fd088f8df6b03fcb65d
|
|
| BLAKE2b-256 |
34fed04e2d64f63a5646aa4f675e0e76d399e422ffbe6ffb67acecb1d8264084
|
Provenance
The following attestation bundles were made for mysql_event_stream-1.0.1-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.0.1-py3-none-manylinux_2_17_aarch64.whl -
Subject digest:
1274a592d0b08e3cd06ab877f3d07f04ab23bc0095747afa7dd300f904c75309 - Sigstore transparency entry: 1186444201
- Sigstore integration time:
-
Permalink:
libraz/mysql-event-stream@0434ea80d0ef833684d03d92183626773e935ead -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/libraz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0434ea80d0ef833684d03d92183626773e935ead -
Trigger Event:
push
-
Statement type:
File details
Details for the file mysql_event_stream-1.0.1-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: mysql_event_stream-1.0.1-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.5 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f652e7a04d4bfc6ea54647c72db4c1ac0797cc42a4459a9a59212ab888db8626
|
|
| MD5 |
b643b9cc0c0ee2b338fff8aedddcca98
|
|
| BLAKE2b-256 |
7885b5431ac8d7d4e3d320cd146f73c66ab1f0d53c3907344d2d61378d230d4c
|
Provenance
The following attestation bundles were made for mysql_event_stream-1.0.1-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.0.1-py3-none-macosx_11_0_arm64.whl -
Subject digest:
f652e7a04d4bfc6ea54647c72db4c1ac0797cc42a4459a9a59212ab888db8626 - Sigstore transparency entry: 1186444206
- Sigstore integration time:
-
Permalink:
libraz/mysql-event-stream@0434ea80d0ef833684d03d92183626773e935ead -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/libraz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0434ea80d0ef833684d03d92183626773e935ead -
Trigger Event:
push
-
Statement type:
File details
Details for the file mysql_event_stream-1.0.1-py3-none-macosx_10_15_x86_64.whl.
File metadata
- Download URL: mysql_event_stream-1.0.1-py3-none-macosx_10_15_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: Python 3, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b796cb4a6f09e8a00b8b65fdf5b70af7eb3289c2436c826c205b31192f1bf98e
|
|
| MD5 |
54640e65f2ca92ea850680900816e860
|
|
| BLAKE2b-256 |
5f1359ea49a5106cfe853e3ef89afd0427bcd9f91a916a9c7c82cdff3e8c9ffd
|
Provenance
The following attestation bundles were made for mysql_event_stream-1.0.1-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.0.1-py3-none-macosx_10_15_x86_64.whl -
Subject digest:
b796cb4a6f09e8a00b8b65fdf5b70af7eb3289c2436c826c205b31192f1bf98e - Sigstore transparency entry: 1186444193
- Sigstore integration time:
-
Permalink:
libraz/mysql-event-stream@0434ea80d0ef833684d03d92183626773e935ead -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/libraz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0434ea80d0ef833684d03d92183626773e935ead -
Trigger Event:
push
-
Statement type: