import mysql.connector
mycon= mysql.connector.connect(
host='localhost',
user='root',
password='password',
database='School')
# Display all the records of students who are in the Medical stream:
if mycon.is_connected():
print('Database connected')
cursor = mycon.cursor()
sql ="SELECT * FROM STUDENT WHERE Stream='Medical' "
cursor.execute(sql)
records = cursor.fetchall()
print("Answer for a):")
for rec in records:
print(rec)
# Change the Class of Divakar to 12C:
sql ="UPDATE STUDENT SET Class='12C' WHERE Name='Divakar'"
cursor.execute(sql)
mycon.commit()
print("Record Updated")
# Display the maximum mark of students in class 12:
sql ="SELECT MAX(AvgMark) FROM STUDENT WHERE Class='12'"
cursor.execute(sql)
max_mark = cursor.fetchone()[0]
print("Answer for c):")
print("The maximum mark in class 12 is:{max_mark}")
mycon.close()