pymysql dataframe 写入sql

import pandas as pd
import pymysql
from sqlalchemy import create_engine


#engine = create_engine("mysql+pymysql://user:password@host:port/databasename?charset=utf8") 
engine = create_engine("mysql+pymysql://root:08300734@127.0.0.1:3306/lgttcc?charset=utf8") 
import tushare as ts 

df=ts.get_hist_data('000001')

df.to_sql(name = 'stock',con = engine,if_exists = 'append',index = False,index_label = False)
posted @ 2018-06-19 22:36  luoganttcc  阅读(559)  评论(0编辑  收藏  举报