python3pymysql查询结果包含字段名
python2使⽤MySQLdb模块进⾏连接mysql数据库进⾏操作;python3则使⽤pymysql模块进⾏连接mysql数据库进⾏操作;两者在语法上有稍微的差别,其中就包括查询结果包含字段名,具体例⼦如下:
python2:
import MySQLdb英语介词短语
干部档案conn = t(host='127.0.0.1',ur='root',passwd='root',db='adu')
cur = conn.cursor(cursorclass=MySQLdb.cursors.DictCursor)
sql = 'lect * from test1'
reCount = ute(sql)
nRet = cur.fetchall()
激励语录cur.clo()
2002年多少岁conn.clo()
print(nRet)
print(reCount)
白色裤子配什么颜色上衣好看pytnon3:
import pymysql
conn = t(host='127.0.0.1',ur='root',passwd='root',db='adu')
cur = conn.cursor(cursor=pymysql.cursors.DictCursor)
sql = 'lect * from test1'
罗伯特彭斯reCount = ute(sql)
养心安神汤nRet = cur.fetchall()
cur.clo()
conn.clo()
print(nRet)猪八戒戴花歇后语
print(reCount)