0% found this document useful (0 votes)
4 views

( Record 16 ) Python mysql interface updation[1]

Uploaded by

yohanmathew1906
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

( Record 16 ) Python mysql interface updation[1]

Uploaded by

yohanmathew1906
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

#yohan - 12136

#Record Program 16
#Source Code
import mysql.connector
mydb = mysql.connector.connect(host ='localhost',user ='root',password='admin',database='cvt11')
mycursor = mydb.cursor()
print("student record updation")
rno = int(input("Enter rno to update the record:"))
query = "select*from student where Roll_no={}".format(rno)
mycursor.execute(query)
myrec = mycursor.fetchone()
if myrec != None:
print('## Record Found - Details are: ##')
print(myrec)
ch = input('Do you want to update marks (y/n):')
if ch == 'y':
marks = float(input('Enter new updated marks:'))
query ='UPDATE student set marks ={} where Roll_no ={}'.format(marks,rno)
mycursor.execute(query)
mydb.commit()
print("## Record(s) updated ##")
else:
print('Sorry ! No such student exists')
mydb.close()

#yohan - 12136
#Record Program 16
#Output
student record updation
Enter rno to update the record:12003
## Record Found - Details are: ##
(12003, 'DIVYA', 70.5, 'C')
Do you want to update marks (y/n):y
Enter new updated marks:72.1
## Record(s) updated ##

#Sucharitha Kapuluru - 12131


#Record Program 16
#Table Used

You might also like