首页 > 数据库技术 > 详细

python---连接MySQL第三页

时间:2015-11-05 13:19:16      阅读:164      评论:0      收藏:0      [点我收藏+]

用python语言从MySQL中查询数据

#!conding:utf-8
from mysql.connector import errorcode
import mysql.connector

cnx=None
cursor=None
try:
    cnx = mysql.connector.connect(host=192.168.1.201,port=3306,user=admin,password=131417)
    cursor=cnx.cursor()
    cursor.execute(select * from studio.t where id=%s,(7,))
    for x in cursor:
        print x

except mysql.connector.Error,err:
    print err

finally:
    if cursor is not None:
        cursor.close()
        cnx.close()

 

python---连接MySQL第三页

原文:http://www.cnblogs.com/JiangLe/p/4939096.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!