CBSE Class 12 Computer Science Question 34 of 47

Interface Python with SQL — Question 12

Back to all questions
12
Question

Question 12

Write a program to increase salary of the employee, whose name is "MANOJ KUMAR", by 3000.

Answer
import mysql.connector
mydb = mysql.connector.connect(host = "localhost",
                                user = "root",
                                passwd = "tiger",
                                database = "School")
mycursor = mydb.cursor()
mycursor.execute("UPDATE employee SET salary = salary + 3000 WHERE Ename = 'MANOJ KUMAR'")
mydb.commit()