Skip to content

Instantly share code, notes, and snippets.

@julien-duponchelle
Created December 6, 2013 23:03
Show Gist options
  • Save julien-duponchelle/7833666 to your computer and use it in GitHub Desktop.
Save julien-duponchelle/7833666 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Dump all replication events from a remote mysql server
#
from pymysqlreplication import BinLogStreamReader
import gc
MYSQL_SETTINGS = {
"host": "127.0.0.1",
"port": 3306,
"user": "root",
"passwd": ""
}
def main():
# server_id is your slave identifier, it should be unique.
# set blocking to True if you want to block and wait for the next event at
# the end of the stream
stream = BinLogStreamReader(connection_settings=MYSQL_SETTINGS,
server_id=3,
blocking=True)
for binlogevent in stream:
binlogevent.dump()
gc.collect()
stream.close()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment