@@ -41,12 +41,13 @@ class ReportSlave(object):
41
41
when connecting as a slave to a master. SHOW SLAVE HOSTS related.
42
42
"""
43
43
44
- def __init__ (self , value : Union [str , Tuple [str , str , str , int ]]) -> None :
44
+ def __init__ (self , value : Union [str , Tuple [str , str , str , int ], Dict [ str , Union [ str , int ]] ]) -> None :
45
45
"""
46
46
Attributes:
47
- value: string or tuple
47
+ value: string, tuple or dict
48
48
if string, then it will be used hostname
49
49
if tuple it will be used as (hostname, user, password, port)
50
+ if dict, keys 'hostname', 'username', 'password', 'port' will be used.
50
51
"""
51
52
self .hostname : str = ''
52
53
self .username : str = ''
@@ -342,7 +343,7 @@ def __connect_to_stream(self) -> None:
342
343
343
344
if not self .auto_position :
344
345
if self .is_mariadb :
345
- prelude : ByteString = self .__set_mariadb_settings ()
346
+ prelude = self .__set_mariadb_settings ()
346
347
else :
347
348
# only when log_file and log_pos both provided, the position info is
348
349
# valid, if not, get the current position from master
@@ -355,7 +356,7 @@ def __connect_to_stream(self) -> None:
355
356
self .log_file , self .log_pos = master_status [:2 ]
356
357
cur .close ()
357
358
358
- prelude : ByteString = struct .pack ('<i' , len (self .log_file ) + 11 ) \
359
+ prelude : bytes = struct .pack ('<i' , len (self .log_file ) + 11 ) \
359
360
+ bytes (bytearray ([COM_BINLOG_DUMP ]))
360
361
361
362
if self .__resume_stream :
@@ -455,7 +456,7 @@ def __connect_to_stream(self) -> None:
455
456
self ._stream_connection ._next_seq_id = 1
456
457
self .__connected_stream : bool = True
457
458
458
- def __set_mariadb_settings (self ) -> ByteString :
459
+ def __set_mariadb_settings (self ) -> bytes :
459
460
# https://mariadb.com/kb/en/5-slave-registration/
460
461
cur : Cursor = self ._stream_connection .cursor ()
461
462
if self .auto_position != None :
@@ -472,7 +473,7 @@ def __set_mariadb_settings(self) -> ByteString:
472
473
4 # requested binlog file name , set it to empty
473
474
)
474
475
475
- prelude : ByteString = struct .pack ('<i' , header_size ) + bytes (bytearray ([COM_BINLOG_DUMP ]))
476
+ prelude : bytes = struct .pack ('<i' , header_size ) + bytes (bytearray ([COM_BINLOG_DUMP ]))
476
477
477
478
# binlog pos
478
479
prelude += struct .pack ('<i' , 4 )
0 commit comments