1.tushare连接mysql,保存tk数据到数据库。(zwpython)

http://www.jianshu.com/p/1039699b0e2e

#!/usr/bin/python

# coding: UTF-8

"""

Created on Wed Mar 29 17:26:55 2017

@author: NuNu

"""

from sqlalchemy import create_engine

import tushare as ts

df = ts.get_tick_data('600848', date='2014-12-22')

engine = create_engine("mysql+pymysql://root:123456@localhost:3306/test?charset=utf8")

#存入数据库

df.to_sql('tick_data',engine)

#追加数据到现有表

#df.to_sql('tick_data',engine,if_exists='append')

你可能感兴趣的:(1.tushare连接mysql,保存tk数据到数据库。(zwpython))