Reputation: 1
import mysql.connector
db = mysql.connector.connect(host="localhost", user="1234", passwd="1234", database="books1")
mycursor = db.cursor()
label = '202'
position = 'A1'
sql2 = """INSERT INTO info (label, position) VALUES (%s, %s)"""
db2 = (label, position)
mycursor.execute(sql2, db2)
print("Updated")
When I run code it says updated but whenever I checked and refresh my sql database the old table appears.
How do I update here my latest input data?
Upvotes: 0
Views: 69
Reputation: 61
You have to commit the transaction. Add db.commit() after mycursor.execute()
Upvotes: 2