pandas读取excel导入数据库的方式

import pandasas pd

import os

import pymysql

from sqlalchemyimport create_engine

engine = create_engine('mysql+pymysql://root:密码@8.140.145.98:3306/数据库名?charset=utf8', encoding ='utf-8')

work_conn_read = engine.connect()

df = pd.read_excel('./RTX_TAPD对应名单1223.xlsx')

df.to_sql('project_personnel', con = work_conn_read, if_exists ='append', index =False)

你可能感兴趣的:(pandas读取excel导入数据库的方式)