Created
December 6, 2013 23:03
-
-
Save julien-duponchelle/7833666 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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