[root@virtdb55 py]# vi tuledict.py
import MySQLdb as mdb
import os,time,sys
import commands as co
import datetime
user = 'root'
password = '123456'
servername='192.168.2.55'
con_1 = mdb.connect(servername,'root','123456','mysql');
cur_1 = con_1.cursor()
cur_1.execute("select id,user,host,db,state,time,info from information_schema.processlist order by time desc")
rows = cur_1.fetchall()
d0 = {}
for row in rows:
d0[row[0]]=dict(id=row[0],user=row[1],host=row[2],db=row[3],state=row[4],time=row[5],info=row[6])
l = []
for k,v in d0.items():
l.append(v)
print l
cur_1.close()
con_1.close()
~
import MySQLdb as mdb
import os,time,sys
import commands as co
import datetime
user = 'root'
password = '123456'
servername='192.168.2.55'
con_1 = mdb.connect(servername,'root','123456','mysql');
cur_1 = con_1.cursor()
cur_1.execute("select id,user,host,db,state,time,info from information_schema.processlist order by time desc")
rows = cur_1.fetchall()
d0 = {}
for row in rows:
d0[row[0]]=dict(id=row[0],user=row[1],host=row[2],db=row[3],state=row[4],time=row[5],info=row[6])
l = []
for k,v in d0.items():
l.append(v)
print l
cur_1.close()
con_1.close()
~
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/91975/viewspace-2131201/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/91975/viewspace-2131201/