Python3 dateframe数据写入mysql

#python3.6.2

import pandas as pd
import pymysql
from sqlalchemy import create_engine

engine = create_engine("mysql+pymysql://user:password@host:port/databasename?charset=utf8") # 这里一定要写成mysql+pymysql,不要写成mysql+mysqldb
df = pd.read_excel('a.xls')

df.to_sql(name = 'table_name',con = engine,if_exists = 'append',index = False,index_label = False)
--------------------- 
作者:focox 
来源:CSDN 
原文:https://blog.csdn.net/zhuyiang/article/details/77161971 
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自blog.csdn.net/weixin_42575593/article/details/83181538