0

i'm trying to update my database mysql using python but it not work

import mysql.connector
mydb = mysql.connector.connect(
host="myhost",
user="myuser",
password="mypass",
database="mydb"
)

prezzo = 385

mycursor = mydb.cursor()
sql = "Update calendario set costo_volo = \"prezzo\" where id_data = '753'"
mycursor.execute(sql)

mydb.commit()

print(mycursor.rowcount, "Prezzo Aggiornato! (prezzo €)")

If i use the number in the query it work, like this

sql = "Update calendario set costo_volo = 385 where id_data = '753'"

How i can use the variable?

robert081
  • 5
  • 4

0 Answers0