0% found this document useful (0 votes)
6 views2 pages

Interface

This cheat sheet provides essential Python-MySQL commands for CBSE Class XII Computer Science students, including database connection, table creation, record insertion, display, updating, and deletion. Key exam strategies emphasize the importance of using parameterized queries and the correct sequence of operations. Students are advised to focus on SQL logic rather than output for exam success.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Interface

This cheat sheet provides essential Python-MySQL commands for CBSE Class XII Computer Science students, including database connection, table creation, record insertion, display, updating, and deletion. Key exam strategies emphasize the importance of using parameterized queries and the correct sequence of operations. Students are advised to focus on SQL logic rather than output for exam success.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CBSE – Class XII (083) VENICERAJAN Computer Science

PYTHON–MYSQL LAST-DAY CHEAT SHEET


CBSE Class XII Computer Science (083) – 2025–26

1. Database Connection (MEMO- ( rno ,)


)
RISE) for row in cur :
print ( row )
import mysql . connector

con = mysql . connector . connect ( 6. Update Record (VERY HIGH


host =" localhost " ,
user =" root " , )
password =" root " ,
database =" School " cur . execute (
) " UPDATE Student SET Marks = Marks +5
cur = con . cursor () WHERE Marks <40"
)
Exam Tip: If connection code is correct → ½ con . commit ()

mark confirmed
Most-repeated logic: Grace marks / condition-
2. Create Table based update

cur . execute ( 7. Delete Record


" CREATE TABLE Student (

N
Rno INT , cur . execute (
JA
Name VARCHAR (20) , " DELETE FROM Student WHERE Rno =% s " ,
Marks INT ) " ( rno ,)
) )
RA

con . commit ()

3. Insert Record (MOST ASKED


8. Count Records
CE

)
cur . execute (" SELECT COUNT (*) FROM Student
sql = " INSERT INTO Student VALUES (% s ,% s ,% s
")
NI

)"
for row in cur :
data = (1 ," Ravi " ,85)
print ( row [0])
cur . execute ( sql , data )
VE

con . commit ()
9. Condition-Based Display
Exam Tip: Without commit() → marks lost
cur . execute (
4. Display Records " SELECT * FROM Student WHERE Marks >75"
)
cur . execute (" SELECT * FROM Student ") for row in cur :
for row in cur : print ( row )
print ( row )

10. Close Connection (DON’T


5. Search by Roll No
FORGET)
rno = int ( input () )
cur . execute ( con . close ()
" SELECT * FROM Student WHERE Rno =% s " ,

FINAL EXAM STRATEGY (READ ONCE)


• Always write connect → cursor → execute → commit → close

• Use parameterised query (%s)

• Avoid advanced SQL

1
CBSE – Class XII (083) VENICERAJAN Computer Science

• SQL logic matters more than output

You are now 100% ready for Python–MySQL questions

N
JA
RA
CE
NI
VE

You might also like