sqlalchemy + pandas + 中文

#连接
engine = create_engine('mysql+pymysql://***:***@localhost:3306/test?charset=utf8')
# #读取
# ret = pd.read_sql_query("select * from testtable",engine)
# print(ret)
#写入
data0 = pd.read_excel('d:/综合信息查询_成交回报.xls')
print(data0)

ret2 = data0.to_sql('o32',engine,if_exists='append')
print(ret2)

中文

create_engine的时候在后边加上 ?charset = utf8

http://firefish.blog.51cto.com/298258/112794/

原文地址:https://www.cnblogs.com/ppqchina/p/6373150.html