CBSE Class 12 Computer Science
Question 40 of 46
Interface Python with MySQL — Question 2
Back to all questionsTable Student of MySQL database School
| rollno | name | marks | grade | section | project |
|---|---|---|---|---|---|
| 101 | RUHANII | 76.8 | A | A | PENDING |
| 102 | GEOGRE | 71.2 | B | A | SUBMITTED |
| 103 | SIMRAN | 81.2 | A | B | EVALUATED |
| 104 | ALI | 61.2 | B | C | ASSIGNED |
| 105 | KUSHAL | 51.6 | C | C | EVALUATED |
| 106 | ARSIYA | 91.6 | A+ | B | SUBMITTED |
| 107 | RAUNAK | 32.5 | F | B | SUBMITTED |
import mysql.connector as mysql
db_con = mysql.connect(
host = "localhost",
user = "root",
password = "tiger",
database = "School"
)
cursor = db_con.cursor()
cursor.execute("SELECT * FROM Student WHERE grade = 'A'")
student_records = cursor.fetchall()
for student in student_records:
print(student)
db_con.close()(101, 'RUHANII', 76.8, 'A', 'A', 'PENDING')
(103, 'SIMRAN', 81.2, 'A', 'B', 'EVALUATED')