CBSE 2026 · Central · Set 4 · Q35 · 4 marks
Peter has created a table named Account in MySQL database, SCHOOL, having following structure : - Stud_id - integer - Sname - string - Class - string - Fees - float Help him in writing a Python program to display records of those students whose fees is less than 5000. Note the following to establish connectivity between Python and MySQL : - Username - admin - Password - root - Host - localhost
Marking-scheme solution
import pymysql as pm # OR import mysql.connector as pm
DB = pm.connect(host='localhost',user='admin', \
password='root', database = 'SCHOOL'))
CUR = DB.cursor()
SQL = "SELECT * FROM Account WHERE Fees<5000"
CUR.execute(SQL)
Data=CUR.fetchall( )
for D in Data:
print(D)
DB.close()
import pymysql as pm # OR import mysql.connector as pm
DB = pm.connect(host='localhost',user='admin', \
password='root', database = 'SCHOOL'))
CUR = DB.cursor()
SQL = "SELECT * FROM Account WHERE Fees<5000"
CUR.execute(SQL)
for C in CUR:
print(C)
DB.close() SECTION E (2x5=$\displaystyle 10$)Python-MySQL Connectivityfetchone(), fetchall() and rowcountApplycase_study
CBSE Class 12 Computer Science past-paper question from the 2026board exam, with the answer as CBSE’s own marking scheme gives it. Where our answers come from.