我正在尝试使用python在mysql表中添加一行。
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, %s, %s, %s, %s, %s, %s, %s)",
(match_id, fair_odds_1, mkt_odds_1, pred_prob_1, exp_return_1, edge_1, scatter_edge, scatter_trend, 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, edge, scatter_edge, scatter_trend, hist_prob, smpl_prop) values (87507, ' at line 1match_id是int,而其余的所有列都是varchar。
我认为问题在于"return“列的名称在MYSQL中是一个关键字。我说的对吗?如果是,那么任何人可以帮助我解决这个问题。谢谢
发布于 2020-08-29 20:39:47
您正在使用关键字return作为字段名称。这可能就是为什么在SQL语句那一部分附近出现错误的原因。
这是一个list of the reserved keywords in MySQL。
为了避免这个问题,只需在关键字周围添加反引号(`)即可。
https://stackoverflow.com/questions/63645649
复制相似问题