首页 > 数据库技术 > 详细

pyhon MySQLdb查询出来的数据设置为字典类型

时间:2015-01-08 16:58:26      阅读:211      评论:0      收藏:0      [点我收藏+]

import MySQLdb
import MySQLdb.cursors

cxn=MySQLdb.Connect(host=‘localhost‘,user=‘root‘,passwd=‘1234‘,db=‘db_name‘,port=3306,\
                    cursorclass=MySQLdb.cursors.DictCursor,charset="utf8")

cur=cxn.cursor()

cur.execute("select * from tablename")

for i in cur.fetchall():

    print type(i)

    break;

pyhon MySQLdb查询出来的数据设置为字典类型

原文:http://www.cnblogs.com/wushirenfei/p/4211178.html

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