fork download
  1. import mysql.connector
  2. mycon = mysql.connector.connect(
  3. host='localhost',
  4. user='root',
  5. password='password',
  6. database='School')
  7. if mycon.is_connected():
  8. print('Database connected')
  9. cursor = mycon.cursor()
  10. sql ="SELECT MAX(AvgMark) FROM STUDENT WHERE Class='12'"
  11. cursor.execute(sql)
  12. max_mark = cursor.fetchone()[0]
  13. print("Answer is:")
  14. print("The maximum mark in class 12 is: {max_mark}")
  15. mycon.close()
Success #stdin #stdout 0.04s 25460KB
stdin
Standard input is empty
stdout
import mysql.connector
mycon = mysql.connector.connect(
     host='localhost',
     user='root',
     password='password',
     database='School')
if mycon.is_connected():
   print('Database connected')
cursor = mycon.cursor()
sql ="SELECT MAX(AvgMark) FROM STUDENT WHERE Class='12'"
cursor.execute(sql)
max_mark = cursor.fetchone()[0]
print("Answer is:")
print("The maximum mark in class 12 is: {max_mark}")
mycon.close()