-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelect.py
More file actions
118 lines (105 loc) · 3.12 KB
/
Select.py
File metadata and controls
118 lines (105 loc) · 3.12 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from Object import ConntectDB
DIR = { 0 : '人文',1 : '艺术',2 : '计算机',3 : '科技',4 : '杂志',5 : '其他'}
def GetBookByBookname(bookName):
conn = ConntectDB()
cur = conn.cursor()
cur.execute("select * from book where bookName = '%s'" % bookName)
l=cur.fetchall()
res = []
for i in l:
t = (i[2],i[3],i[1],i[4],DIR[i[5]],i[6])
res.append(t)
return res
def GetBookByBookType(bookType):
conn = ConntectDB()
cur = conn.cursor()
cur.execute("select * from book where bookType = %s" % bookType)
l=cur.fetchall()
res = []
for i in l:
t = (i[2],i[3],i[1],i[4],DIR[i[5]],i[6])
res.append(t)
return res
def GetBookByBookAuthor(bookAuthor):
conn = ConntectDB()
cur = conn.cursor()
cur.execute("select * from book where bookAuthor = '%s'" % bookAuthor)
l=cur.fetchall()
res = []
for i in l:
t = (i[2], i[3], i[1], i[4], DIR[i[5]], i[6])
res.append(t)
return res
def GetIDByNameAndAuthor(name,author):
conn = ConntectDB()
cur = conn.cursor()
cur.execute("select id from book where bookName = '%s' and bookAuthor = '%s' " % (name,author))
res = cur.fetchone()
if res == None:
return None
else:
return res[0]
def GetAllBookID():
conn = ConntectDB()
cur = conn.cursor()
cur.execute("select id from book ")
res=cur.fetchall()
id = []
for i in res:
id.append(i[0])
return id
def GetBookNameByID(id):
conn = ConntectDB()
cur = conn.cursor()
cur.execute("select bookName from book where id = %s" % id)
return cur.fetchone()[0]
def GetAllStu():
conn = ConntectDB()
cur = conn.cursor()
cur.execute("select name,stuID,maxNum,nowNum from student")
return cur.fetchall()
def GetBookNumByID(id):
conn = ConntectDB()
cur = conn.cursor()
cur.execute("select bookNum from book where id = %s" % id)
return cur.fetchone()[0]
def GetBookTimeByID(id):
conn = ConntectDB()
cur = conn.cursor()
cur.execute("select time from book where id = %s" % id)
return cur.fetchone()[0]
def GetStuNumByID(id):
conn = ConntectDB()
cur = conn.cursor()
cur.execute("select maxNum,nowNum from student where id = %s" % id)
return cur.fetchone()
def GetAllBorrowbookByStuID(id):
conn = ConntectDB()
cur = conn.cursor()
cur.execute("select bookID from borrow where stuID = %s" % id)
res = cur.fetchall()
l = []
for i in res:
l.append(i[0])
return l
def GetAllBorrowInfoByStuid(id):
conn = ConntectDB()
cur = conn.cursor()
cur.execute("select * from borrow where stuID = %s" % id)
res = cur.fetchall()
l = []
for i in res:
t = GetBookNameAuthorByID(i[0])
r = (t[0],t[1],i[2],i[3])
l.append(r)
return l
def GetAllBorrowInfoByStuID(id):
conn = ConntectDB()
cur = conn.cursor()
cur.execute("select * from borrow where stuID = %s" % id)
return cur.fetchall()
def GetBookNameAuthorByID(id):
conn = ConntectDB()
cur = conn.cursor()
cur.execute("select bookName,bookAuthor from book where id = %s" % id)
return cur.fetchone()