File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 99from pymysqlreplication .exceptions import StatusVariableMismatch
1010from pymysqlreplication .util .bytes import parse_decimal_from_bytes
1111from typing import Union , Optional
12+ import json
1213
1314
1415class BinLogEvent (object ):
@@ -67,15 +68,27 @@ def _verify_event(self):
6768 self .packet .read_bytes -= 19 + self .event_size + 4
6869 self .packet .rewind (20 )
6970
71+ @property
72+ def formatted_timestamp (self ) -> str :
73+ return datetime .datetime .utcfromtimestamp (self .timestamp ).isoformat ()
74+
7075 def dump (self ):
7176 print (f"=== { self .__class__ .__name__ } ===" )
72- print (f"Date: { datetime . datetime . utcfromtimestamp ( self .timestamp ). isoformat () } " )
77+ print (f"Date: { self .formatted_timestamp } " )
7378 print (f"Log position: { self .packet .log_pos } " )
7479 print (f"Event size: { self .event_size } " )
7580 print (f"Read bytes: { self .packet .read_bytes } " )
7681 self ._dump ()
7782 print ()
7883
84+ def to_dict (self ) -> dict :
85+ return {
86+ "timestamp" : self .formatted_timestamp ,
87+ "log_pos" : self .packet .log_pos ,
88+ "event_size" : self .event_size ,
89+ "read_bytes" : self .packet .read_bytes ,
90+ }
91+
7992 def _dump (self ):
8093 """Core data dumped for the event"""
8194 pass
You can’t perform that action at this time.
0 commit comments