标签:set ble fetchall style char color import sel ldb
import MySQLdb
import MySQLdb.cursors
#sql语句
sql = "select * from table"
#连接数据库
db = MySQLdb.connect(host="localhost",
user="root",
passwd="root1234",
charset="utf8",
port=3306,
cursorclass=MySQLdb.cursors.DictCursor)
#创建游标
a = db.cursor()
#执行sql
rows = a.execute(sql)
#获取所有查询结果
request = a.fetchall()
print rows
print request
#关闭链接
db.close()
标签:set ble fetchall style char color import sel ldb
原文地址:https://www.cnblogs.com/jinbaobao/p/9413113.html