-
Notifications
You must be signed in to change notification settings - Fork 0
/
member.py
74 lines (52 loc) · 1.88 KB
/
member.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import mysql.connector as sqlt
import pandas as pd
from tabulate import tabulate
con=sqlt.connect(host="localhost",user="root",passwd="Rishi@638963",database="library")
cursor=con.cursor()
def member_input():
try:
memberid=int(input("Enter Member Id"))
membername = input("Enter Member Name")
mem_add=input("Enter Member Address")
phone = input("Enter Phone No")
qry="insert into member values({},'{}','{}','{}');".format(memberid,membername,mem_add,phone)
cursor.execute(qry)
con.commit()
print("Added Successfully.")
except:
print("SORRY...THIS MEMBER ID IS ALREADY EXISTING..TRY OTHER MEMBER ID")
def member_edit():
x=int(input("Enter Member Id"))
qry = "select * from member where memberid={};".format(x)
cursor.execute(qry)
r=cursor.fetchone()
if r:
y=input("Enter New Address")
qry = "update member set mem_add = '{}' where memberid = {};".format(y,x)
cursor.execute(qry)
con.commit()
print("Edited Successfully.")
else :
print("Wrong Member Id")
def member_delete():
x= int(input("Enter Member Id"))
qry="select * from member where memberid = {};".format(x)
cursor.execute(qry)
r=cursor.fetchone()
if r:
qry="delete from member where memberid={};".format(x)
cursor.execute(qry)
con.commit()
print("Deleted Successfully.")
else:
print("Wrong Member Id")
def member_search():
x=int(input("Enter Member Id"))
qry="select * from member where memberid = {};".format(x)
cursor.execute(qry)
r=cursor.fetchone()
if r:
df = pd.read_sql(qry,con)
print(tabulate(df,headers = 'keys',tablefmt = 'psql',showindex = False))
else:
print("Wrong Member Id")