In my python code, I want to update the table value as per the user input so i need to pass the dynamic value in the query but i am not able to get any result. Can you suggest me way?
Below is my code:`
import mysql.connector
zone = # Dynamic value
rate = # Dynamic value
conn=mysql.connector.connect(user='root',password='1234',host='localhost',database='demo')
mycursor=conn.cursor()
mycursor.execute("UPDATE interest_rate SET interest=(rate,) where Bank_Name=%s",(zone,))
conn.commit()
`
How to pass the rate in the UPDATE query, I am able to pass the zone variable in the query. Can you help me to pass the rate variable?
I am using python 3.4 and MySQL as the database.