运行结果只显示最后一行第218行,前面的不显示,错在哪里?
import pymysqlsql = "select id,name,category,price,category1,publish_time from hadoopdata"
def main():
try:
db = pymysql.connect(host="localhost",user="root",password="123456",database="pysql")
cursor = db.cursor()
cursor.execute(query=sql)
for user_row in cursor.fetchall():
id = user_row[0]
name =user_row[1]
category = user_row[2]
price = user_row[3]
category1 = user_row[4]
publish_time = user_row[5]
print("%s %s %s %s %s %s " % (id,name,category,price,category1,publish_time))
except exception:
print("error"+traceback.format_exc())
finally:
db.close()
if __name__=="__main__":
main()
#运行结果只显示最后一行第218行的数据,前面的不显示,错在哪里?表在MYSQL里查询此表格是有218条数据的
#218 自粘聚合物改性沥青防水卷材 -218 -218.00 -218 2019-08-01
#进程已结束,退出代码0