@@ -40,7 +40,7 @@ def __init__(self, connection_settings, server_id, resume_stream=False,
40
40
filter_non_implemented_events = True ,
41
41
ignored_events = None , auto_position = None ,
42
42
only_tables = None , only_schemas = None ,
43
- freeze_schema = False ):
43
+ freeze_schema = False , skip_to_timestamp = None ):
44
44
"""
45
45
Attributes:
46
46
resume_stream: Start for event from position or the latest event of
@@ -54,6 +54,7 @@ def __init__(self, connection_settings, server_id, resume_stream=False,
54
54
only_tables: An array with the tables you want to watch
55
55
only_schemas: An array with the schemas you want to watch
56
56
freeze_schema: If true do not support ALTER TABLE. It's faster.
57
+ skip_to_timestamp: Ignore all events until reaching specified timestamp.
57
58
"""
58
59
self .__connection_settings = connection_settings
59
60
self .__connection_settings ["charset" ] = "utf8"
@@ -82,6 +83,7 @@ def __init__(self, connection_settings, server_id, resume_stream=False,
82
83
self .log_pos = log_pos
83
84
self .log_file = log_file
84
85
self .auto_position = auto_position
86
+ self .skip_to_timestamp = skip_to_timestamp
85
87
86
88
def close (self ):
87
89
if self .__connected_stream :
@@ -259,6 +261,9 @@ def fetchone(self):
259
261
self .__only_schemas ,
260
262
self .__freeze_schema )
261
263
264
+ if self .skip_to_timestamp and binlog_event .timestamp < self .skip_to_timestamp :
265
+ continue
266
+
262
267
if binlog_event .event_type == TABLE_MAP_EVENT and \
263
268
binlog_event .event is not None :
264
269
self .table_map [binlog_event .event .table_id ] = \
0 commit comments