import mysql.connector
conn = mysql.connector.connect(host='192.168.15.32', port='3306', user='devuser', password='1001hk', database='dx20', \
use_unicode=True)
cursor = conn.cursor()
cursor.execute('select id,phone,real_name from t_user order by id desc limit 10')
values = cursor.fetchall()
for row in values:
id = row[0]
phone = row[1]
realName = row[2]
if (realName is None):
print (id, phone, realName)
else:
print 'USERID:%s, PHONE:%s , realName: %s' % (id, phone, realName.encode('utf-8').decode('utf-8'))
cursor.close()
conn.close()