I've been following this previous answer, however I still get a syntax error:
cursor.execute ("""
UPDATE tblTableName
SET Year=%s, Month=%s, Day=%s, Hour=%s, Minute=%s
WHERE Server=%s
""", (Year, Month, Day, Hour, Minute, ServerID))
My code is:
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))
The table then looks like:
The syntax error is:
_mysql_exceptions.ProgrammingError: (1064....near ''OilProvedReservesHistory' SET US = '36.533' WHERE ID=1' at line 1
Can you spot the error? ?Thanks