#python3.6.2
import pandas as pd
import pymysql
from sqlalchemy import create_engine
# 这里一定要写成mysql+pymysql,不要写成mysql+mysqldb
engine = create_engine("mysql+pymysql://user:password@host:port/databasename?charset=utf8")
df = pd.read_excel('a.xls')
df.to_sql(name = 'table_name',con = engine,if_exists = 'append',index = False,index_label = False)
————————————————
版权声明:本文为CSDN博主「focox」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zhuyiang/article/details/77161971