From 8c660ecaeefc326eecf76cf2bef6f111c00da1c8 Mon Sep 17 00:00:00 2001 From: gombos Date: Sun, 9 Oct 2011 18:32:24 +0000 Subject: [PATCH] added some sql to search --- cli/worblehat.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/worblehat.py b/cli/worblehat.py index 45ea697..0dc1e2b 100755 --- a/cli/worblehat.py +++ b/cli/worblehat.py @@ -272,7 +272,11 @@ def search_book(connection, search_strings, search_description=False): else: 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)) + c.execute('SELECT isbn,book.id AS id,title,category, \ + array_to_string(array_agg(person.lastname || \' (\' || person.id || \')\', \', \') AS persons \ + 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): book = fetchone_dict(c) print book['isbn'], book['title'], book['person']