class mysql.utilities.parser.GeneralQueryLog(stream)
这个类解析MySQL 通用查询日志。实例是可以迭代的,不过该类不提供多个独立的迭代器的。如读取日志并打印数目:
1
2
3
4
|
>>> 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)
这个类解析MySQL慢查询日志的。实例是可以迭代的,不过该类不提供多个独立的迭代器的。如读取日志并打印数目:
1
2
3
4
|
>>> 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 |
文章转载来自:trustauth.cn