Advertisements
Advertisements
प्रश्न
The code given below deletes the record from the table employee, which contains the following record structure:
E_code - StringE_name - StringSal - IntegerCity - String
Note the following to establish connectivity between Python and MySQL:
- Username is
root - Password is
root - The table exists in a MySQL database named
emp. - The details
(E_code, E_name, Sal, City)are the attributes of the table.
Write the following statements to complete the code:
Statement 1 – to import the desired library.
Statement 2 – to execute the command that deletes the record with E_code as 'E101'.
Statement 3 – to delete the record permanently from the database. ____________
import ____________ as mysql #Statement1
def delete():
mydb=mysql.connect(host="localhost",use r="root",
passwd="root",database="emp")
mycursor=mydb.cursor()
____________ #Statement 2
____________ #Statement 3
print ("Record deleted") कोड लेखन
Advertisements
उत्तर
Statement1: mysql.connector
Statement2: mycursor.execute("Delete from emp where E_code='E101'")
Statement3: mydb.commit() shaalaa.com
SQL for Data Definition
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
