您好,我正在关注Python MYSQL 更新语句并设法为我的程序的 SQL 更新生成此代码,其中包含变量函数:
def editInfo(start, userName):
newFavGenre = input("Enter your favourite genre")
newFavArtist = input("Enter your favourite artist")
## userName is a global variable
con = lite.connect(db)
cur = con.cursor()
cur.execute ("""
UPDATE users
SET favGenre=%s, favArtist=%s
WHERE username=%s
""", (newFavGenre, newFavArtist, userName))
results = cur.fetchall()
return result
mainmenu()
并继续体验此错误代码:
sqlite3.OperationalError: near "%": syntax error
有什么想法我哪里出错了吗?