Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any tool available to parse mysql binlog file in row format and create json

I have mysql binlog enabled in row format. I am using mysqlbinlog to parse binlog file. I am using this command:

 mysqlbinlog --base64-output=decode-rows -vv ./mysql-bin.000004

This command returns sql statements that I have to parse to generate json.

I used pymysqlreplication module in python but it doesn't read from binlog file. It requires real-time mysql replication connection. I can't access archived binlog files using master server.

Is there any way to parse archived binlog file and generate json?

like image 528
Branel Moro Avatar asked Sep 11 '25 02:09

Branel Moro


2 Answers

You can use binlog-parser.

A tool for parsing a MySQL binlog file to JSON. Reads a binlog input file, queries a database for field names, writes JSON to stdout.

like image 51
Peter Avatar answered Sep 12 '25 17:09

Peter


You can use

https://github.com/noplay/python-mysql-replication

This is used by several independent projects as mentioned on their page.

I have created a separate binlog parser based on sqlparse(python). The link to that :

https://github.com/monothorn/mysql-parser
like image 22
saurabh Avatar answered Sep 12 '25 18:09

saurabh