-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmembers.py
75 lines (58 loc) · 1.9 KB
/
members.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
75
import mysql.connector as ms
from db_credentials import setu
def get_memid(mem_name):
id = setu.cursor()
query = "SELECT member_id from members where full_name=\'"+mem_name+"\';"
id.execute(query);
mem_id = id.fetchall()
if mem_id == []:
return -1;
else:
return mem_id[0][0]
def add_new_member(m_type, m_mno, email_id,m_fullname):
add = setu.cursor()
query = "INSERT into members(member_type,mobile_number,email_id,full_name) values(%s,%s,%s,%s)"
val = (m_type,m_mno,email_id,m_fullname)
add.execute(query,val)
setu.commit()
print(add.rowcount," Member record inserted")
def display_all_members1():
arz = setu.cursor()
arz.execute("SELECT member_type, member_id, full_name, mobile_number, email_id FROM members")
allMembers = arz.fetchall()
return allMembers
def display_all_members():
arz = setu.cursor()
arz.execute("SELECT * FROM members")
allMembers = arz.fetchall()
return allMembers
def search_member_by_id(m_id):
arz = setu.cursor()
query = "SELECT * FROM members where member_id="+str(m_id)
arz.execute(query)
searchMember = arz.fetchall()
return searchMember
def search_member_by_name1(m_name):
arz = setu.cursor()
query = "SELECT member_type, member_id, full_name, mobile_number, email_id FROM members where full_name like\'"+str(m_name)+"%\'"
print(query)
arz.execute(query)
searchMember = arz.fetchall()
print(searchMember)
if searchMember == []:
return -1;
else:
return searchMember;
#return searchMember
def search_member_by_name(m_name):
arz = setu.cursor()
query = "SELECT * FROM members where full_name like\'"+str(m_name)+"%\'"
print(query)
arz.execute(query)
searchMember = arz.fetchall()
print(searchMember)
if searchMember == []:
return -1;
else:
return searchMember;
#return searchMember