Description:
My slow query log contains records
# User@Host: root[root] @ foo.example.com [10.10.10.1]
# User@Host: a-b[a-b] @ my-host [10.10.10.1]
Trying to parse with mysql.utilities.common.parser.SlowQueryLog leads to error
with File "C:\Python27\lib\mysql\utilities\common\parser.py", line 546, in _parse_line
line[:30])
mysql.utilities.exception.LogParserError: ('Failed parsing Slow Query line: # User@Host: root[root] @ foo', 0)
When I use host with out of dot it works perfectly.
I am sure regular expression is wrong
How to repeat:
Open your slow query log. Change host name so it contains dots.
For example
# User@Host: root[root] @ foo.example.com [10.10.10.1]
Install mysql package for python from MySQL workbench.
Run the following python script:
from mysql.utilities.common import parser
for entry in parser.SlowQueryLog(open("c:/temp/1.log")):
print entry.query
Suggested fix:
Fix regex. Add dashes and dots to user name group and host group
34,35c34,35
< r"(?:([\w\d]+))?\s*"
< r"\[\s*([\w\d]+)\s*\]\s*"
---
> r"(?:([-\w\d]+))?\s*"
> r"\[\s*([-\w\d]+)\s*\]\s*"
37c37
< r"([\w\d]*)\s*"
---
> r"([-\w.\d]*)\s*"