Interface of Python with MySQL: Class 12 PYQs 2024–2026 with solutions
All 3 CBSE board questions asked from Interface of Python with MySQL in 3 board papers, with the year, set and marks of each. 2 are solved free below. The Class 12 Computer Science PYQ Book: Solved Board Papers 2024-2026 (CBSE) has every solution, all chapters and 3 full board papers.
Interface of Python with MySQL: board weightage
Board weightage 2024–2026
| Year | 2024 | 2025 | 2026 |
|---|---|---|---|
| Questions | 1 | 1 | 1 |
| Marks | 4 | 4 | 4 |
Most asked topics
3 questions from 3 papers. Repeated questions are shown once with every year they were asked.
Jump to: 4 marks
4 marks: SQL / case-based
Table Account in MySQL database SCHOOL: Stud_id int, Sname, Class, Fees float. Display records of students whose fees is less than 5000. Username admin, password root, host localhost.
Solution
import mysql.connector as pm # or import pymysql as pm(Looping directly over the cursor,
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()
for C in CUR: print(C), also works.)Table THEATRE in database CINEMA: Th_ID char(5), Name varchar(15), City varchar(15), Location varchar(15), Seats int. Write Delete_Theatre() to input Th_ID from the user and permanently delete that record. Host localhost, user root, password Ex2025.
Solution
import mysql.connector as pm # or import pymysql as pm
def Delete_Theatre():
Mydb = pm.connect(host='localhost', user='root',
password='Ex2025', database='CINEMA')
MyCursor = Mydb.cursor()
TID = input("Theatre ID: ")
Query = "DELETE FROM THEATRE WHERE Th_ID = %s"
MyCursor.execute(Query, (TID,))
# or: Query = "DELETE FROM THEATRE WHERE Th_ID='{}'".format(TID)
# MyCursor.execute(Query)
Mydb.commit() # "permanently" → commit
Mydb.close()
(A)(ii) Sunil wants to update the quantity to 20 of the records whose item code is 111 in table shop (Item_code, Item_name, Qty, Price) of MySQL database Keeper. Username admin, password Shopping, host localhost.
OR (B)(i) Give any two features of SQL. (ii) Sumit wants to display all details from table flight (F_code, F_name, Source, Destination) in database Travel; username root, password airplane, host localhost.
Get every solution for all chapters
- Every board question of every chapter, each fully solved the way the board gives marks
- 3 complete board papers, each followed by its solutions
- Weightage and most-asked topics for every chapter
- Instant PDF download, colour and black & white print copies
Revising the chapter first? Complete Computer Science Notes for Class 12 (CBSE 083, 2026-27) →
What you get in the pack
- CBSE Class 12 Computer Science board papers 2024 to 2026 (3 full board papers)
- All 14 chapters and 3 board papers complete
- Part A: all 14 chapters, questions sorted chapter-wise and by marks
- Year-wise weightage table and most-asked topics for every chapter
- Part B: each full board paper followed by its complete solutions
- Full programs; every output traced and verified by running the code
- Only the current syllabus in Part A
All chapters in this pack
- PYQ Ch 1 Python Revision Tour
- PYQ Ch 2 Functions
- PYQ Ch 3 Exception Handling
- PYQ Ch 4 Text Files
- PYQ Ch 5 Binary Files
- PYQ Ch 6 CSV Files
- PYQ Ch 7 Stack
- PYQ Ch 8 Computer Networks I: Evolution and Data Communication
- PYQ Ch 9 Computer Networks II: Devices, Topologies and Types
- PYQ Ch 10 Network Protocols and Web Services
- PYQ Ch 11 Database Concepts
- PYQ Ch 12 SQL: DDL, DML and Queries
- PYQ Ch 13 SQL: Aggregates, Grouping and Joins
- PYQ Ch 14 Interface of Python with MySQL
- Board Paper 2026 Set 91 with Solutions
- Board Paper 2025 Set 91 with Solutions
- Board Paper 2024 Set 91 with Solutions
