मराठी

Sartaj has created a table named Student in MYSQL database, SCHOOL: rno(Roll number )- integer name(Name) - string DOB (Date of birth) – Date

Advertisements
Advertisements

प्रश्न

Sartaj has created a table named Student in MYSQL database, SCHOOL:

  • rno(Roll number )- integer
  • name(Name) - string
  • DOB (Date of birth) – Date
  • Fee – float

Note the following to establish connectivity between Python and MySQL:

  • Username - root
  • Password - tiger
  • Host - localhost

Sartaj, now wants to display the records of students whose fee is more than 5000. Help Sartaj to write the program in Python.

टीपा लिहा
Advertisements

उत्तर

import mysql.connector as mysql
con1 = mysql.connect (host="localhost", user="root", password="tiger", database="sample2023")
mycursor=con1.cursor()
query = "SELECT * FROM student where fee>{}".format (5000)
mycursor.execute(query)
data=mycoursor.fetchall()
for rec in data:
print (rec)
con1.close()
shaalaa.com
Data Types and Constraints in MySQL
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2023-2024 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×