मराठी

A table, named THEATRE, in CINEMA database, has the following structure: Field Th_ID Name City Location Seats Type char (5) varchar (15) varchar (15) varchar (15) int Write a function Delete - Computer Science (Python)

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
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2024-2025 (March) Set 4
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×