成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術(shù)文章
文章詳情頁

python - 數(shù)據(jù)無法插入到mysql表里

瀏覽:134日期:2022-08-26 16:11:11

問題描述

# -*- conding:utf8 -*-import tushare as tsimport pymysqltoday_data = ts.get_today_all()conn = pymysql.connect(host=’127.0.0.1’, port=3306, user=’root’, passwd=’root’, db=’test’)cursor = conn.cursor() #創(chuàng)建游標cursor.execute('INSERT INTO today_data(code_code,name_name,changepercent,trade,open_open,high_high,low_low,settlement,volume,turnoverratio,amount,per,pb_pb,mktcap,nmc) VALUES (’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’)',format(code_code,name_name,changepercent,trade,open_open,high_high,low_low,settlement,volume,turnoverratio,amount,per,pb_pb,mktcap,nmc))cursor.close()

上面是代碼,下面是報錯信息

[Getting data:]#######################################Traceback (most recent call last): File 'C:/Users/Administrator/PycharmProjects/untitled/test.py', line 7, in <module> cursor.execute('INSERT INTO today_data(code_code,name_name,changepercent,trade,open_open,high_high,low_low,settlement,volume,turnoverratio,amount,per,pb_pb,mktcap,nmc) VALUES (’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’,’{}’)',format(code_code,name_name,changepercent,trade,open_open,high_high,low_low,settlement,volume,turnoverratio,amount,per,pb_pb,mktcap,nmc))NameError: name ’code_code’ is not defined

test中是有today_data表的,表里也有這些字段,變量today_data獲取到的數(shù)據(jù)也有這些字段,求指導

問題解答

回答1:

異常不是提示你了么?code_code 變量沒有定義

標簽: Python 編程
相關(guān)文章: