cursor.execute(sql2)
conn.commit()row=cursor.fetchall()for i in row: print i[root@zabbix_server ~]# cat bb.pyimport MySQLdbconn=MySQLdb.connect(host='ip',user='xxx',passwd='xxx',port=xxx,db='xxxx',charset='utf8')cursor =conn.cursor()sql2="select ip,username,password FROM xxx.xxx"cursor.execute(sql2)
conn.commit()row=cursor.fetchone()for i in row: print i
[root@zabbix_server ~]# python bb.py
192.168.X.XXXXXXX[root@zabbix_server ~]# python aa.py(u'192.168.X.X1', u'XXX', u'XXX')(u'192.168.X.X2', u'XXX', u'XXX')(u'192.168.X.X3', u'XXX', u'XXX')