gpt4 book ai didi

python - 我怎样才能不出现 mysql 转换元组错误?

转载 作者:行者123 更新时间:2023-11-29 09:45:36 25 4
gpt4 key购买 nike

我只想使用 UPDATE 命令刷新。这给出了错误,我哪里出错了?

for checkNewAbility in list(newAbilities1):
if not checkNewAbility in list(oldAbility[1]):
my_cursor.execute(
"UPDATE mydb.skill SET skill_name='%s' WHERE Person_person_id='%s'
AND skill_id='%d';",(checkNewAbility, url[0], oldAbility[0]))
realdb.commit()

错误:

"Failed processing format-parameters; %s" % err)mysql.connector.errors.ProgrammingError: Failed processingformat-parameters; Python 'tuple' cannot be converted to a MySQL type

我的列表有:

oldAbility= [(43, 'PHP'), (44, 'HTML'), (45, 'CSS')]

newAbilities1= ['Java', 'Python', 'JavaScript']

I just want to replace oldAbilities with newAbilities1 according to id.

最佳答案

如果您正确地复制并粘贴了代码,则在execute(后缺少双引号“”。我假设您使用pyodbc。

for checkNewAbility in list(newAbilities1):
if not checkNewAbility in list(oldAbility[1]):
my_cursor.execute("UPDATE mydb.skill SET skill_name='?' WHERE Person_person_id='?' AND skill_id='?'", (checkNewAbility, url[0], oldAbility[0]))
realdb.commit()

关于python - 我怎样才能不出现 mysql 转换元组错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55761158/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com