File: replication.py

package info (click to toggle)
python-asyncmy 0.2.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 676 kB
  • sloc: python: 3,528; makefile: 40
file content (26 lines) | stat: -rw-r--r-- 673 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import asyncio

from asyncmy import connect
from asyncmy.replication import BinLogStream
from asyncmy.replication.row_events import DeleteRowsEvent, UpdateRowsEvent, WriteRowsEvent
from conftest import connection_kwargs


async def main():
    conn = await connect(**connection_kwargs)
    ctl_conn = await connect(**connection_kwargs)

    stream = BinLogStream(
        conn,
        ctl_conn,
        1,
        resume_stream=True,
        blocking=True,
        only_events=[WriteRowsEvent, UpdateRowsEvent, DeleteRowsEvent],
    )
    async for event in stream:
        print(event.schema, event.table, event.rows)


if __name__ == "__main__":
    asyncio.run(main())