【发布时间】:2021-11-10 05:08:33
【问题描述】:
我的变量值来自编辑后的网格单元格。该功能有效,但编辑的字段名称名为“读取”。我通过更改列名来修复它,但我很好奇为什么这是一个错误以及是否应该避免任何其他字段名称标题。
Message=(1064, "您的 SQL 语法有错误;请查看与您的 MySQL 服务器版本相对应的手册,了解在 'Read = 'ALL' where User_ID = 'j_adams58' 附近使用的正确语法' 在第 1 行")
表格字段
|用户ID |密码 |阅读 |编辑 |
def onCellChanged(self,event):
#Establish connection
self.connect_mysql()
#Update database
key_id = str(self.GetCellValue(event.GetRow(),1))
target_col = str(self.GetColLabelValue(event.GetCol()))
key_col = str(self.GetColLabelValue(1))
nVal = self.GetCellValue(event.GetRow(),event.GetCol())
sql_update = f"""Update {tbl} set {target_col} = %s where {key_col} = %s"""
row_data = ''
self.cursor.execute(sql_update, (nVal, key_id,))
#Close connection
self.close_connection()
【问题讨论】:
标签: python mysql-python