Q. Write a Python database connectivity script that deletes records from category table of database items that have name = 'Stockable'
Answer =
import mysql.connector as ctor dbcon = ctor.connect (host = "localhost", user = "learner", passwd = "fast", database = "items") cursor = dbcon.cursor() sql1 = "DELETE FROM category WHERE name = '%s' " data1 = ('Stockable',) cursor.execute(sql1, data1) dbcon.commit() print("Rows affected: ", cursor.rowcount) dbcon.close()
Where is the output??
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )