我一直在关注这个先前的答案,但是我仍然收到语法错误:
cursor.execute ("""
UPDATE tblTableName
SET Year=%s, Month=%s, Day=%s, Hour=%s, Minute=%s
WHERE Server=%s
""", (Year, Month, Day, Hour, Minute, ServerID))
我的代码是:
def postToMySQL(data,fieldname,table,col):
if fieldname == "Year":
sql = "INSERT INTO " + table + " ("+ fieldname + ") VALUES (%s)"
c.execute(sql, data)
else:
c.execute ("""
UPDATE %s
SET US=%s
WHERE ID=%s
""", (table, data, col))
然后该表如下所示:
语法错误是:
_mysql_exceptions.ProgrammingError: (1064..near ''OilProvedReservesHistory' SET US = '36.533' WHERE ID=1' at line 1'
你能发现错误吗??谢谢