1.读取数据库
import pymysql
id=[]
name=[]
explain=[]
db=pymysql.Connection(host="localhost",port=,user="root", password="root",database="jiansuo",charset="utf8")
cursor=db.cursor()
sql="select * from yuan"
try:
cursor.execute(sql)
results=cursor.fetchall()
for row in results:
id.append(row[])
name.append(row[])
explain.append(row[])
except:
print("出错了!")
db.close()
2.写入数据库
import pymysql
id=[]
name=[]
explain=[]
db=pymysql.Connection(host="localhost",port=,user="root", password="root",database="jiansuo",charset="utf8")
cursor=db.cursor()
sql="select * from yuan"
try:
cursor.execute(sql)
results=cursor.fetchall()
for row in results:
id.append(row[])
name.append(row[])
explain.append(row[])
except:
print("出错了!")
db.close()