Mysql Update Syntax Error Python
我一直在关注这个先前的答案,但是我仍然收到语法错误:
堆栈溢出答案
1
2 3 4 5 |
cursor.execute ("""
UPDATE tblTableName SET Year=%s, Month=%s, Day=%s, Hour=%s, Minute=%s WHERE Server=%s """, (Year, Month, Day, Hour, Minute, ServerID)) |
我的代码是:
1
2 3 4 5 6 7 8 9 10 |
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
你能发现错误吗? ?谢谢
应该是这样的,没有引号
SET US = ‘36.533’
你能试试这个吗:
1
2 3 |
UPDATE %s
SET US=%s WHERE ID=%s |
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/python/268016.html