-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.py
28 lines (25 loc) · 1.03 KB
/
update.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import mysql.connector
conn=mysql.connector.connect(
host='localhost',
database='ums',
user='root',
password='deepthi@2000'
)
cur=conn.cursor()
class update:
def deptupdate(x,colname,ndeptname,odeptname):
cur.execute(f"update department set {colname}='{ndeptname}' where {colname}='{odeptname}'")
conn.commit()
print("Data has been updated successfully.")
def courseupdate(x,colname,newvalue,oldvalue):
cur.execute(f"update course set {colname}={newvalue} where {colname}={oldvalue}")
conn.commit()
print("Data has been updated successfully")
def facultyupdate(x,colname,newval,oldval):
cur.execute(f"update faculty set {colname}='{newval}' where {colname}='{oldval}'")
conn.commit()
print("Data has been updated successfully")
def studentupdate(x,colname,newone,oldone):
cur.execute(f"update student set {colname}='{newone}' where {colname}='{oldone}'")
conn.commit()
print("Data has been updated successfully")