This module provides classes for parsing MySQL log files. Currently, Slow Query Log and General Query Log are supported.
class mysql.utilities.parser.GeneralQueryLog(stream)
This class parses the MySQL General Query Log. Instances are iterable, but the class does not provide multiple independent iterators.
For example, to read the log and print the entries:
>>> general_log = open("/var/lib/mysql/mysql.log") >>> log = GeneralQueryLog(general_log) >>> for entry in log: ... print entry
Parameters: |
|
version
Returns: | Version of the MySQL server that produced the log |
Return type: | tuple |
program
Returns: | Full path of the MySQL server executable |
Return type: | str |
port
Returns: | TCP/IP port on which the MySQL server was listening |
Return type: | int |
socket
Returns: | Full path of the MySQL server Unix socket |
Return type: | str |
start_datetime
Returns: | Date and time of the first read log entry |
Return type: | datetime.datetime |
lastseen_datetime
Returns: | Date and time of the last read log entry |
Return type: | datetime.datetime |
class mysql.utilities.parser.SlowQueryLog(stream)
This class parses the MySQL Slow Query Log. Instances are iterable, but the class does not provide multiple independent iterators.
For example, to read the log and print the entries:
>>> slow_log = open("/var/lib/mysql/mysql-slow.log") >>> log = SlowQueryLog(slow_log) >>> for entry in log: ... print entry
Parameters: |
|
version
Returns: | Version of the MySQL server that produced the log |
Return type: | tuple |
program
Returns: | Full path of the MySQL server executable |
Return type: | str |
port
Returns: | TCP/IP port on which the MySQL server was listening |
Return type: | int |
socket
Returns: | Full path of the MySQL server Unix socket |
Return type: | str |
start_datetime
Returns: | Date and time of the first read log entry |
Return type: | datetime.datetime |
lastseen_datetime
Returns: | Date and time of the last read log entry |
Return type: | datetime.datetime |
User Comments
Add your own comment.