python Mysql实现

上一篇 / 下一篇  2015-06-02 09:37:07 / 个人分类:测试生活日志


#coding=utf-8
import MySQLdb
#建立数据库连接
conn = MySQLdb.connect(host="xxxxxxxxx",user='xxx',passwd='xxx',db='xxx',port=3306)
sql = "select * from CaboxProgram where tvId='xxx' and nibble1Id='xxx' and nibble2Id='xxx'"
#执行数据库操作
#cursor返回游标的连接对象
curs = conn.cursor()
curs.execute(sql)
res = curs.fetchall()
print type(res)   #返回是元祖
print len(res)
print res[0]
curs.close()
conn.close()



TAG: Python python

 

评分:0

我来说两句

日历

« 2024-04-27  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 93357
  • 日志数: 31
  • 建立时间: 2015-05-22
  • 更新时间: 2016-05-17

RSS订阅

Open Toolbar