Python MYSQL update statement

前端 未结 5 1614
时光取名叫无心
时光取名叫无心 2020-11-27 02:27

I\'m trying to get this Python MYSQL update statement correct(With Variables):

cursor.execute (\"UPDATE tblTableName SET Year=%s\" % Year \", Month=%s\" % Mo         


        
5条回答
  •  情歌与酒
    2020-11-27 03:18

    You've got the syntax all wrong:

    cursor.execute ("""
       UPDATE tblTableName
       SET Year=%s, Month=%s, Day=%s, Hour=%s, Minute=%s
       WHERE Server=%s
    """, (Year, Month, Day, Hour, Minute, ServerID))
    

    For more, read the documentation.

提交回复
热议问题