Skip to content

Commit b204bdd

Browse files
Merge pull request julien-duponchelle#144 from baloo/features/slave_uuid
Support for slave_uuid
2 parents b9bbee5 + c6ae6b8 commit b204bdd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pymysqlreplication/binlogstream.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def __init__(self, connection_settings, server_id, resume_stream=False,
128128
ignored_events=None, auto_position=None,
129129
only_tables=None, only_schemas=None,
130130
freeze_schema=False, skip_to_timestamp=None,
131-
report_slave=None):
131+
report_slave=None, slave_uuid=None):
132132
"""
133133
Attributes:
134134
resume_stream: Start for event from position or the latest event of
@@ -144,6 +144,7 @@ def __init__(self, connection_settings, server_id, resume_stream=False,
144144
freeze_schema: If true do not support ALTER TABLE. It's faster.
145145
skip_to_timestamp: Ignore all events until reaching specified timestamp.
146146
report_slave: Report slave in SHOW SLAVE HOSTS.
147+
slave_uuid: Report slave_uuid in SHOW SLAVE HOSTS.
147148
"""
148149
self.__connection_settings = connection_settings
149150
self.__connection_settings["charset"] = "utf8"
@@ -176,6 +177,7 @@ def __init__(self, connection_settings, server_id, resume_stream=False,
176177

177178
if report_slave:
178179
self.report_slave = ReportSlave(report_slave)
180+
self.slave_uuid = slave_uuid
179181

180182
def close(self):
181183
if self.__connected_stream:
@@ -241,6 +243,11 @@ def __connect_to_stream(self):
241243
cur.execute("set @master_binlog_checksum= @@global.binlog_checksum")
242244
cur.close()
243245

246+
if self.slave_uuid:
247+
cur = self._stream_connection.cursor()
248+
cur.execute("set @slave_uuid= '%s'" % self.slave_uuid)
249+
cur.close()
250+
244251
self._register_slave()
245252

246253
if not self.auto_position:

0 commit comments

Comments
 (0)