CBSE Class 12 Computer Science
Question 33 of 47
Interface Python with SQL — Question 11
Back to all questionsTable Employee:
| EMPNO | ENAME | DEPT | SALARY |
|---|---|---|---|
| 1 | RAJESH | IT | 60000 |
| 2 | MANOJ KUMAR | HISTORY | 65000 |
| 3 | ANUSHA | MARKETING | 70000 |
| 4 | ABHAY | FASHION STUDIES | 45000 |
import mysql.connector
mydb = mysql.connector.connect(host = "localhost",
user = "root",
passwd = "tiger",
database = "School")
mycursor = mydb.cursor()
mycursor.execute("select * FROM EMPLOYEE ORDER BY SALARY")
myrecords = mycursor.fetchall()
for row in myrecords:
print(row)
mycursor.close()
mydb.close()(4, 'ABHAY', 'FASHION STUDIES', 45000.0)
(1, 'RAJESH', 'IT', 60000.0)
(2, 'MANOJ KUMAR', 'HISTORY', 65000.0)
(3, 'ANUSHA', 'MARKETING', 70000.0)