import pymysql
# 数据库查询操作
# fetchone() 获取下一个查询结果集 ,结果集是一个对象
# fetchall() 接收全部的返回的行
# rowcount 是一个只读属性,返回execute()方法影响的行数
db = pymysql.connect("localhost", "root", "wsw..177122", "wakey")
cursor = db.cursor()
sql = 'select * from bandcard where money>400'
try:
cursor.execute(sql)
reslist = cursor.fetchall()
for row in reslist:
print("%d--%d" % (row[0], row[1])) # 打印键值对
except:
db.rollback()
cursor.close()
db.close()