# mysql数据库生成PANDAS数据
import pymysql
import pandas as pd
pymysql.install_as_MySQLdb()
"""请关注 www.jjddlc.com"""
"""作者:Pgabc"""
def mysql_pandas(itemnv_nv,item_code):
#从MYSQL生成PANDOS数据
global df_wm,df
db = pymysql.connect(host='127.0.0.1', user='root', passwd='XXXXXXXXXXXX', db='stock', charset='utf8')
cursor = db.cursor()
query = " select ts_code,trade_date,open,high,low,close,vol,pre_close from {0} where ts_code='{1}'".format(itemnv_nv,item_code)
df_wm = pd.read_sql(query,db)
df = pd.DataFrame(df_wm)
return df_wm,df
if __name__=="__main__":
itemnv_nv = 'stock_daily'
item_code = '600666'
mysql_pandos1(itemnv_nv, item_code)
python 数据分析中mysql数据库生成pandas数据
最新推荐文章于 2022-09-03 23:11:33 发布