Skip to content Skip to sidebar Skip to footer

Python MySQL Update Table

How To Update The Selected Row In MySQL Database Table Using Python

How To Update The Selected Row In MySQL Database Table Using Python Python MySQL Update Table


import mysql.connector

connection = mysql.connector.connect(
host='localhost',
user='root', password='',
port='3306',
database='test_py'
)
c = connection.cursor()

def updateData():
update_query = """UPDATE `users_2` SET
`firstname`=%s,`lastname`=%s,
`email`=%s,`age`=%s
WHERE `id` =%s """

vals = ("NewFName","NewLName","[email protected]",56,5)

c.execute(update_query,vals)

connection.commit()


updateData()


OUTPUT:

How To Update The Selected Row In MySQL Database Table Using Python Python MySQL Update Table
Python MySQL Update - Before Updating

How To Update The Selected Row In MySQL Database Table Using Python Python MySQL Update Table
Python MySQL Update - After Updating




▶ Download Python Projects Source Code

Post a Comment for "Python MySQL Update Table"