Interface of Python with MySQL Class 12 PYQs 2024–2026 with Solutions | CBSE Computer Science Skip to content
Smart Notes for Every Exam · instant PDF download after payment +91 92520 37565
Class 12 · Computer Science · Chapter 14

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.

Cover of Class 12 Computer Science PYQ Book: Solved Board Papers 2024-2026 (CBSE)
Class 12 Computer Science PYQ book: every chapter + 3 board papers, all solved
US$1.99US$1.9934% off
Free sample

Interface of Python with MySQL: board weightage

Board weightage 2024–2026

Year202420252026
Questions111
Marks444

Most asked topics

Python–MySQL connectivity3

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

Q1 · CBSE 2026 · 91 · Q354 marks

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
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()
(Looping directly over the cursor, for C in CUR: print(C), also works.)

Q2 · CBSE 2025 · 91 · Q354 marks

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()

Q3 · CBSE 2024 · 91 · Q354 marks

(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.

Full step-by-step solution is in the PYQ book (US$1.99).

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
See real pages (free sample)

Revising the chapter first? Complete Computer Science Notes for Class 12 (CBSE 083, 2026-27) →

What you get in the pack

All chapters in this pack

  1. PYQ Ch 1 Python Revision Tour
  2. PYQ Ch 2 Functions
  3. PYQ Ch 3 Exception Handling
  4. PYQ Ch 4 Text Files
  5. PYQ Ch 5 Binary Files
  6. PYQ Ch 6 CSV Files
  7. PYQ Ch 7 Stack
  8. PYQ Ch 8 Computer Networks I: Evolution and Data Communication
  9. PYQ Ch 9 Computer Networks II: Devices, Topologies and Types
  10. PYQ Ch 10 Network Protocols and Web Services
  11. PYQ Ch 11 Database Concepts
  12. PYQ Ch 12 SQL: DDL, DML and Queries
  13. PYQ Ch 13 SQL: Aggregates, Grouping and Joins
  14. PYQ Ch 14 Interface of Python with MySQL
  15. Board Paper 2026 Set 91 with Solutions
  16. Board Paper 2025 Set 91 with Solutions
  17. Board Paper 2024 Set 91 with Solutions
← PYQ Ch 13 SQL: Aggregates, Grouping and Joins Board Paper 2026 Set 91 with Solutions →

Prices shown in US dollars. Show prices in: ₹ INR · US$ USD