diff --git a/cli/worblehat.py b/cli/worblehat.py index 6d58a74..55e6c48 100755 --- a/cli/worblehat.py +++ b/cli/worblehat.py @@ -265,10 +265,16 @@ def list_cmd(connection, what): def search_book(connection, search_strings, search_description=False): c = connection.cursor() - c.execute('SELECT * FROM book WHERE book.title LIKE %(search_strings)s', {"search_strings": '%' + search_strings[0] + '%'}) + where_clauses = ['book.title ILIKE %s OR book.subtitle ILIKE %s OR book.series ILIKE %s OR person.lastname ILIKE %s OR person.firstname ILIKE %s']*len(search_strings) + result_list = [] + for s in search_strings: + for i in range(5): + result_list.append(s) + c.execute('SELECT * FROM book LEFT JOIN bookperson ON book.isbn=bookperson.book LEFT JOIN person ON person.id=bookperson.person WHERE ' + ' OR '.join(where_clauses), map(lambda s:'%' + s + '%',result_list)) for i in xrange(c.rowcount): - cat = fetchone_dict(c) - print cat['title'] + book = fetchone_dict(c) + print book['isbn'], book['title'], book['person'] + def search_person(connection, search_strings): pass