Last active
June 12, 2017 23:55
-
-
Save adxrgh/e2b4c41fe86d4bdec0543fb2b94c7788 to your computer and use it in GitHub Desktop.
[单表sql,sql table读写]#tags:IO,sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###sql文件信息读写 | |
import tushare as ts | |
import pymysql | |
import pandas as pd | |
from pandas import DataFrame as df | |
#下载数据并写入 | |
a=ts.get_today_all() | |
from sqlalchemy import create_engine | |
e=create_engine('mysql+pymysql://'+'root:1235@localhost/yaotest?charset=utf8') | |
a.to_sql('a',e,if_exists='replace') | |
#从数据库读取数据 | |
b=pd.read_sql_table('a',e) #将整个表读取出来并直接生成了DataFrame | |
b.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment