码迷,mamicode.com
首页 > 数据库 > 详细

python链接mysql pymysql

时间:2019-10-05 20:07:47      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:set   mysq   print   mysql   password   sql   ase   cursor   base   

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

 

python链接mysql pymysql

标签:set   mysq   print   mysql   password   sql   ase   cursor   base   

原文地址:https://www.cnblogs.com/herd/p/11625576.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!