python mysql

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()

  

posted @ 2019-07-02 21:13  ahuo  阅读(134)  评论(0编辑  收藏  举报