I\'m trying to get this Python MYSQL update statement correct(With Variables):
cursor.execute (\"UPDATE tblTableName SET Year=%s\" % Year \", Month=%s\" % Mo
Here is the correct way:
import MySQLdb
if __name__ == '__main__':
connect = MySQLdb.connect(host="localhost", port=3306,
user="xxx", passwd="xxx", db='xxx', charset='utf8')
cursor = connect.cursor()
cursor.execute("""
UPDATE tblTableName
SET Year=%s, Month=%s, Day=%s, Hour=%s, Minute=%s
WHERE Server=%s
""", (Year, Month, Day, Hour, Minute, ServerID))
connect.commit()
connect.close()
P.S. Don't forget connect.commit(), or it won't work