I am getting the following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near %s How do I add a variable to my sql query?
#!/usr/bin/python
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="",
password="",
database="seahub_db"
)
mycursor = mydb.cursor()
ip = "Myip"
sql = "UPDATE constance_config SET value = %s WHERE id=1"
mycursor.execute(sql, ip)
mydb.commit()
mycursor.close()
mydb.close()