运维开发网

python链接mysql pymysql

运维开发网 https://www.qedev.com 2020-07-15 11:31 出处:网络 作者:运维开发网整理
python链接mysql import pymysql conn = pymysql.connect(user=‘user1‘, password=‘123456‘, database=‘gbt2019‘, charset=‘utf8‘)

python链接mysql

import pymysql

conn = pymysql.connect(user=‘user1‘, password=‘123456‘, database=‘gbt2019‘, charset=‘utf8‘)
cursor = conn.cursor()
query = (‘select id, title from data_2019100501‘)
cursor.execute(query)
for (id, title) in cursor:
    print(id, title)
cursor.close()
conn.close()
0

精彩评论

暂无评论...
验证码 换一张
取 消