CBSESetWise.in

Class 12 Computer Science: Python-MySQL Connectivity PYQs (2022–2026)

Authentic CBSE board questions & official stepwise marking scheme solutions for Python-MySQL Connectivity (Chapter 9).

Python-MySQL Connectivity PYQs (2022–2026)

Practical questions on connecting Python with MySQL databases using mysql.connector: establishing connection, creating cursor, executing SELECT/INSERT queries, and fetchone()/fetchall() results with complete answer key.

Key Topics: mysql.connector Import & connect(), cursor Creation & execute(), cur.fetchone() vs cur.fetchall(), commit() and rollback(), Parameterized Database Search

Python-MySQL Connectivity Previous Year Questions & Solutions (6 Questions)

Q35 • CBSE 2026 • 4 Marks • Python-MySQL Connectivity (Chapter 9)

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) (2026) 4-Mark Board Question Q35

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) 2026 4 Mark PYQ Q35
Official CBSE Marking Scheme Solution

import mysql.connector con = mysql.connector.connect(host="localhost", user="admin", password="root", database="SCHOOL") cur = con.cursor() cur.execute("SELECT * FROM Account WHERE Fees < 5000") for row in cur.fetchall(): print(row) cur.close(); con.close()

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) 2026 4 Mark PYQ Q35 Official Solution
Q35 • CBSE 2025 • 4 Marks • Python-MySQL Connectivity (Chapter 9)

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) (2025) 4-Mark Board Question Q35

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) 2025 4 Mark PYQ Q35
Official CBSE Marking Scheme Solution

import mysql.connector def Delete_Theatre(): tid = input("Enter Th_ID: ") con = mysql.connector.connect(host="localhost", user="root", password="x2025", database="CINEMA") cur = con.cursor() cur.execute("DELETE FROM THEATRE WHERE Th_ID = %s", (tid,)) con.commit() cur.close(); con.close()

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) 2025 4 Mark PYQ Q35 Official Solution
Q35 • CBSE 2024 • 5 Marks • Python-MySQL Connectivity (Chapter 9)

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) (2024) 5-Mark Board Question Q35

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) 2024 5 Mark PYQ Q35
Official CBSE Marking Scheme Solution

Cartesian product pairs every row of one relation with every row of another; if they have m and n rows, the result has m×n rows. import mysql.connector con = mysql.connector.connect(host="localhost", user="admin", password="Shopping", database="Keeper") cur = con.cursor() cur.execute("UPDATE shop SET Qty = 20 WHERE Item_code = 111") con.commit() Two SQL features: it is declarative/non-procedural; it supports data definition and manipulation. import mysql.connector con = mysql.connector.connect(host="localhost", user="root", password="airplane", database="Travel") cur = con.cursor() cur.execute("SELECT * FROM flight") for row in cur.fetchall(): print(row)

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) 2024 5 Mark PYQ Q35 Official Solution
Q16 • CBSE 2023 • 1 Mark • Python-MySQL Connectivity (Chapter 9)

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) (2023) 1-Mark Board Question Q16

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) 2023 1 Mark PYQ Q16
Official CBSE Marking Scheme Solution

Option B — list of tuples.

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) 2023 1 Mark PYQ Q16 Official Solution
Q32 • CBSE 2023 • 5 Marks • Python-MySQL Connectivity (Chapter 9)

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) (2023) 5-Mark Board Question Q32

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) 2023 5 Mark PYQ Q32
Official CBSE Marking Scheme Solution

Statement 1: import mysql.connector as mysql Statement 2: mycursor.execute("DELETE FROM employee WHERE E_code = 'E101'") Statement 3: mydb.commit() alternative The random output is not unique: each displayed value must correspond to valid indices from M according to the randint ranges

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) 2023 5 Mark PYQ Q32 Official Solution
Q4 • CBSE 2022 • 2 Marks • Python-MySQL Connectivity (Chapter 9)

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) (2022) 2-Mark Board Question Q4

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) 2022 2 Mark PYQ Q4
Official CBSE Marking Scheme Solution

fetchone() returns one row as a tuple; repeated fetchone() calls advance through the result set. The displayed output depends on the MEMBER table values. End of answer key. Equivalent correct Python/SQL solutions are acceptable where they achieve the stated task.

CBSE Class 12 Python-MySQL Connectivity (Chapter 9) 2022 2 Mark PYQ Q4 Official Solution

Other Computer Science Chapters

Functions & Exception Handling • Text Files • Binary Files • CSV Files • Stack • Computer Networks • Database Concepts & SQL • Python-MySQL Connectivity