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="192.168.1.19", 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]
    time.sleep(8);
# close the cursor
cur.close()
# close the connection
db.close ()