Code Monkey home page Code Monkey logo

mysql-log-parser's Introduction

Mysql Log parser

Retrieved from mysql-utilities (possibly bundled with MySQL workbench) and made changes for Percona's slow log.

Usage

Example file

# Time: 130131 11:09:34
# User@Host: det5mcxkw6dhenf6[det5mcxkw6dhenf6] @ localhost []
# Thread_id: 11441651  Schema: det5mcxkw6dhenf6
# Query_time: 6.058117  Lock_time: 0.000000  Rows_sent: 0  Rows_examined: 0  Rows_affected: 0  Rows_read: 1
use det5mcxkw6dhenf6;
commit;

Shell Example

In [1]: from mysql_log_parser.parser import SlowQueryLog

In [2]: f = open('mysql-slow-query.log')

In [3]: log = SlowQueryLog(f)

In [4]: log.next()
Out[4]: 
{'database': 'det5mcxkw6dhenf6;',
 'datetime': datetime.datetime(2013, 1, 31, 11, 9, 34),
 'host': 'localhost',
 'lock_time': Decimal('0.000000'),
 'query': 'use det5mcxkw6dhenf6;\ncommit;',
 'query_time': Decimal('6.058117'),
 'rows_affected': 0,
 'rows_examined': 0,
 'rows_read': 1,
 'rows_sent': 0,
 'schema': 'det5mcxkw6dhenf6',
 'session_id': None,
 'thread_id': '11441651',
 'user': 'det5mcxkw6dhenf6'}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.