Oct 10, 2018

A simple python script to keep an eye on mysql process

The following codes are the same, they are just shown on different formats. Choose the one you like.

@author: it.i88.ca
import MySQLdb
import time

db = MySQLdb.connect(host="", user="i88ca", passwd="i88ca", db="i88ca")
#create a cursor for the select
cur = db.cursor()

while (True):    
    cur.execute("show processlist;")

    for row in cur.fetchall() :
    #    print row[0], row[1]
        print row[7]
# close the cursor
# close the connection
db.close ()