pip3 install PyMySQL
import pymysql conn = pymysql.connect(host='mydb.123.cn',port=3306, user='root', passwd="123", db='cinfo') cur = conn.cursor() cur.execute("SELECT cid,phone FROM tb_userinfo") for r in cur: print(r) cur.close() conn.close()
pip3 install PyMySQL
import pymysql conn = pymysql.connect(host='mydb.123.cn',port=3306, user='root', passwd="123", db='cinfo') cur = conn.cursor() cur.execute("SELECT cid,phone FROM tb_userinfo") for r in cur: print(r) cur.close() conn.close()