import pandas as pd
import pymysql
#连接数据库
dbconn=pymysql.connect(
host="0.0.0.0",#ip
database="stockdb",
user="cueb",#用户名
password="cueb",#密码
port=3306,#端口号
charset='utf8'
)
s = "select * from user";
data = pd.read_sql(s, dbconn)
#print(data)
if len(data) > 1:
path = "doc/" + tableName + ".xls"
xlsxdata = pd.DataFrame(data=data)
xlsxdata.to_excel(path, index=False)