I am setting rds with kinesis data stream. Following this article https://aws.amazon.com/blogs/database/streaming-changes-in-a-database-with-amazon-kinesis/. Running the python code, it is not entering the for loop. So problem is with the stream connection. Printing stream gives pymysqlreplication.binlogstream.BinLogStreamReader object at 0xxxxxxxxxxx. Please tell me what I am doing wrong.

I have added ip of my server to security group of rds.

import boto3

from pymysqlreplication import BinLogStreamReader
from pymysqlreplication.row_event import (
  DeleteRowsEvent,
  UpdateRowsEvent,
  WriteRowsEvent,
)

def main():
  mysql = {
      "host": "xxxxxxxxxxxxx.amazonaws.com",
      "port": 3306,
      "user": "xxxx",
      "passwd": "xxx",
      "db": "xxx"}
  kinesis = boto3.client("kinesis", region_name = 'us-xx-xx')

  stream = BinLogStreamReader(
    connection_settings = mysql,
    server_id=100,
    blocking = true,
    log_file='mysql-bin.000003',
    resume_stream=True,
    only_events=[DeleteRowsEvent, WriteRowsEvent, UpdateRowsEvent])
  print stream
  for binlogevent in stream:
    print 1

if __name__ == "__main__":
   main()

0 Answers