我尝试在python中执行以下代码,但导致syntax error near '('
出现executemany(..)
错误。当我从sql
中删除名称并只写%s
时,也会导致错误there are more placeholders thant the variables
有谁知道我怎么解决它?
upInfo ={"aa": "aaa","bb": "bbb","cc": "ccc"}
sql = 'UPDATE table SET a= %(aa)s WHERE b= %(bb)s and c= %(cc)s'
con = pymssql.connect(...)
con.autocommit(True)
cur = con.cursor()
cur.executemany(sql, upInfo)
答案 0 :(得分:0)
由于这是executemany()
,因此它应该是词典列表:
upInfo = [{"aa": "aaa", "bb": "bbb", "cc": "ccc"}]
或者,使用常规execute()
:
cur.execute(sql, upInfo)