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.
Where is the answer dude??
ReplyDeleteAnswer =
DeleteRows affected: 1
Not bad y'all...;)
ReplyDelete^_^
DeletePlz give proper output
ReplyDeleteOk, i will try.
DeleteIt is not nessesary that rowcount only count fetch method, it is counting number of rows affected whether it is fetch, update or insert.
ReplyDeleteHow do u know whether the id is unique or not ?/
ReplyDeleteIn general ID is always unique.
DeleteThanks bruh <3
ReplyDeleteWelcome : )
DeleteThanks 👍
ReplyDeleteWelcome : )
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )