File tree Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change 1
1
2
+
2
3
from flask import request , render_template , make_response
3
4
4
5
from server .webapp import flaskapp , cursor
9
10
def index ():
10
11
name = request .args .get ('name' )
11
12
author = request .args .get ('author' )
12
- read = request .args .get ('read' )
13
+ read = bool ( request .args .get ('read' ) )
13
14
14
15
if name :
15
16
cursor .execute (
16
- "SELECT * FROM books WHERE name LIKE %s" , ( '%' + name + '%' ,)
17
+ "SELECT * FROM books WHERE name LIKE '%" + name + "%'"
17
18
)
18
19
books = [Book (* row ) for row in cursor ]
19
20
20
21
elif author :
21
22
cursor .execute (
22
- "SELECT * FROM books WHERE author LIKE %s" , ('%' + author + '%' ,)
23
- )
24
- books = [Book (* row ) for row in cursor ]
25
-
26
- elif read :
27
- cursor .execute (
28
- "SELECT * FROM books WHERE read LIKE %s" , ('%' + read + '%' ,)
23
+ "SELECT * FROM books WHERE author LIKE '%" + author + "%'"
29
24
)
30
25
books = [Book (* row ) for row in cursor ]
31
26
You can’t perform that action at this time.
0 commit comments