Skip to content

Instantly share code, notes, and snippets.

@mahadirz
Last active January 22, 2022 05:31
Show Gist options
  • Save mahadirz/36830918ae0368d7cf06745f3b45077c to your computer and use it in GitHub Desktop.
Save mahadirz/36830918ae0368d7cf06745f3b45077c to your computer and use it in GitHub Desktop.
mysql_binlog_tutorial
import struct
with open("person.bin", 'rb') as f:
while True:
data = f.read(72)
if not data:
break
unpacked = struct.unpack('<II32s32s', data)
print(f"ID:{unpacked[0]} "
f"Age:{unpacked[1]} "
f"Name: {unpacked[2].decode()} {unpacked[3].decode()}"
f"")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment