# -*- coding: utf-8 -*-

# 导入必要模块
import pandas as pd
from sqlalchemy import create_engine

data=pd.read_excel('knowledge_network.xls')
print(data.head())

# # 初始化数据库连接，使用pymysql模块
engine = create_engine(str(r"mysql+mysqldb://%s:" + '%s' + "@%s:%s/%s") % (root,3SYz54LS9#^9sBvC,'10.66.157.22', 4000, jerry_prod))
# engine = create_engine('mysql+pymysql://root:147369@localhost:3306/mydb')
data.to_sql('testtttttttttttt',con=engine,if_exists='append',index=False)
# # 读取本地CSV文件
# df = pd.read_csv("E://mpg.csv", sep=',')
#
# # 将新建的DataFrame储存为MySQL中的数据表，不储存index列
# df.to_sql('mpg', engine, index= False)

print("Write to MySQL successfully!")