Advertisements
Advertisements
प्रश्न
A table, named THEATRE, in CINEMA database, has the following structure:
Field |
Type |
Th_ID |
char (5) |
Name |
varchar (15) |
City |
varchar (15) |
Location |
varchar (15) |
Seats |
int |
Write a function Delete _Theatre (), to input the value of Th_ ID from the user and permanently delete the corresponding record from the table.
Assume the following for Python-Database connectivity:
Host: localhost, User: root, Password: Ex2025
कोड लेखन
Advertisements
उत्तर
import mysql.connector
def Delete_Theatre():
tid=input("Enter theatre id to delete :")
con=mysql.connector.connect(user = "root",password="Ex2025", host = "localhost", database =
"cinema")
cursor=con.cursor()
sql="Delete from Theatre where
Th_id = '%s" %(tid)
try:
cursor.execute(sql)
con.commit()
except:
con.rollback()
finally:
con.close()shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
