Q.Write code to connect to a MYSQL database namely School and then fetch all those records from table Student where grade is 'A'.



Answer = 

import mysql.connector as a

mydb = a.connect(host="localhost",user="root",password="portal express", database = "Student")

cur = mydb.cursor()

run = "select * from Student where grade = 'A' "

cur . execute(run)

data = cur.fetchall()

for i in data :

    print(i)

mydb.close()

8 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post