Q. Predict the output of the following code:



import mysql.connector 
db = mysql.connector.connect(….) 
cursor db.cursor() 
sql1 = "update category set name = ‘%s’ WHERE ID = %s” % ('CSS',2)
cursor.execute(sql1) 
db.commit() 
print("Rows affected:", cursor.rowcount) 
db.close() 

Answer :-

>>> Rows affected : 1

Because ID is unique so, there will only one row with same data. so, Row affected by this code is only 1.

13 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post