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

python3连接mysql

时间:2017-05-27 19:58:30      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:print   python   0.11   hal   xxx   xxxx   logs   pass   exec   

#!/usr/bin/python3

import pymysql

conn = pymysql.connect(host=10.60.10.11,port=3306,user=root,passwd=xxxxx,db=haoxx)

cur = conn.cursor()

cur.execute("select car_id,car_name from car where car_id < 5")

for i in cur.fetchall():
    print(i)

cur.close()
conn.close()

 

python3连接mysql

标签:print   python   0.11   hal   xxx   xxxx   logs   pass   exec   

原文地址:http://www.cnblogs.com/vijayfly/p/6914097.html

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