Skip to main content

MySQL 8.4 CDC engine - Python binding (native ctypes)

Project description

mysql-event-stream — Python Binding

CI PyPI License Python MySQL Platform

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+ — Supports LTS and Innovation releases
  • GTID support — Native BinlogClient with GTID-based replication
  • 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

MySQL Requirements

  • Version: 8.4+
  • GTID mode enabled (for BinlogClient)
  • Replication privileges: REPLICATION SLAVE, REPLICATION CLIENT

License

Apache-2.0

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mysql_event_stream-1.2.0-py3-none-manylinux_2_17_x86_64.whl (2.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

mysql_event_stream-1.2.0-py3-none-manylinux_2_17_aarch64.whl (2.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

mysql_event_stream-1.2.0-py3-none-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

mysql_event_stream-1.2.0-py3-none-macosx_10_15_x86_64.whl (2.2 MB view details)

Uploaded Python 3macOS 10.15+ x86-64

File details

Details for the file mysql_event_stream-1.2.0-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for mysql_event_stream-1.2.0-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 e3168787b95705231913b87917de3c78fc1b70b37c033b1bb6fd5fed42349fd6
MD5 7f69832b99c6d9fd63f9d2c21b58ba28
BLAKE2b-256 9fbf89ebb7232797db5c953c689a0673d37146ba3fce5333bb7b0a69af709e4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mysql_event_stream-1.2.0-py3-none-manylinux_2_17_x86_64.whl:

Publisher: publish.yml on libraz/mysql-event-stream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mysql_event_stream-1.2.0-py3-none-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for mysql_event_stream-1.2.0-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 e9703095bf817d25d6285e45d2e7c4a882df5af47315261d55a5ebc6cdf985a3
MD5 5b64d031d7c78febc4f6844f94d197e1
BLAKE2b-256 147bbefb0854b1fe541ae325012b3146209d049b6507db603d9f5eac9c4d2d6a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mysql_event_stream-1.2.0-py3-none-manylinux_2_17_aarch64.whl:

Publisher: publish.yml on libraz/mysql-event-stream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mysql_event_stream-1.2.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mysql_event_stream-1.2.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 38262a14208e3175e8ab260e1bebd5e5a5d0f9cd419dd0260797b334f576c7da
MD5 5ee48a51e4a71e7db1c3edc062fc401a
BLAKE2b-256 9fd98a2a6e091ac1ca53cc036fc3a1ae4753308ad6939f53fe5721e831169fd4

See more details on using hashes here.

Provenance

The following attestation bundles were made for mysql_event_stream-1.2.0-py3-none-macosx_11_0_arm64.whl:

Publisher: publish.yml on libraz/mysql-event-stream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mysql_event_stream-1.2.0-py3-none-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for mysql_event_stream-1.2.0-py3-none-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 97cb07dc7fea958b60407555ebf3b6e672e6177be17009a7f759f375066882ab
MD5 f207896da8e3fc681c355b341f031df2
BLAKE2b-256 aa9e6439de9f9f0c0c70fcc13f4b7dff412bf5eb7ffc40af5b519be9c2fbe896

See more details on using hashes here.

Provenance

The following attestation bundles were made for mysql_event_stream-1.2.0-py3-none-macosx_10_15_x86_64.whl:

Publisher: publish.yml on libraz/mysql-event-stream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page