问题描述
cursor.execute(
"insert into tbl_ft1x2s (match_id,fair_odds,mkt_odds,pred_prob,return,edge,scatter_edge,scatter_trend,hist_prob,smpl_prop) values (%s,%s,%s)",(match_id,fair_odds_1,mkt_odds_1,pred_prob_1,exp_return_1,edge_1,hist_prob_1,smpl_prop_1))
我遇到此错误,
MysqL.connector.errors.ProgrammingError: 1064 (42000): You have an error in your sql Syntax; check the manual that corresponds to your MysqL server version for the right Syntax to use near 'return,smpl_prop) values (87507,' at line 1
match_id为int,其余所有列为varchar。
我认为问题在于“ return”列的名称是MysqL中的关键字。我对吗 ?如果是,那么任何人都可以帮助我解决此问题。 谢谢
解决方法
您正在使用关键字return
作为字段名称。这可能就是为什么在SQL语句的该部分附近出现该错误的原因。
这里是list of the reserved keywords in MySQL。
为避免此问题,只需在关键字周围添加反引号(`)。