-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
46 lines (36 loc) · 937 Bytes
/
main.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import pymysql
con = pymysql.connect(host='localhost',
user='root',
password="20btad036",
db='pdbc',
)
def insert(id,name,cgpa):
cur = con.cursor()
sql = "insert into std values(%s,%s,%s)"
std = (id,name,cgpa)
cur.execute(sql,std)
con.commit()
def update(id,name,cgpa):
cur = con.cursor()
sql = "update std set name=%s,gpa=%s where id=%s"
std = (name,cgpa,id)
cur.execute(sql,std)
con.commit()
def select():
cur = con.cursor()
sql = "select * from std"
cur.execute(sql)
result = cur.fetchall()
# return result
for i in result:
print(i[0],i[1],i[2])
# def delete(id):
# cur = con.cursor()
# sql = f"delete form std where id = {id}"
# # std = tuple(id)
# cur.execute(sql)
# con.commit()
# insert(5,"jawa palani",5.5)
# update(5,"java palani",6.5)
# delete(5)
select()