1. 程式人生 > >Python3 dateframe資料寫入mysql

Python3 dateframe資料寫入mysql

#python3.6.2

import pandas as pd import pymysql from sqlalchemy import create_engine

engine = create_engine("mysql+pymysql://user:[email protected]: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  版權宣告:本文為博主原創文章,轉載請附上博文連結!