1 import pymysql2 id=[]3 name=[]4 explain=[]5 db=pymysql.Connection(host="localhost",port=3307,user="root", password="root",database="jiansuo",charset="utf8")6 cursor=db.cursor()7 sql="select * from yuan"
8 try:9 cursor.execute(sql)10 results=cursor.fetchall()11 for row inresults:12 id.append(row[0])13 name.append(row[1])14 explain.append(row[2])15 except:16 print("出错了!")17 db.close()