Projects/worblehat-old
Projects
/
worblehat-old
Archived
12
0
Fork 0

added some sql to search

This commit is contained in:
Péter Henrik Gombos 2011-10-09 18:32:24 +00:00
parent cc4eadc885
commit 8c660ecaee
1 changed files with 5 additions and 1 deletions

View File

@ -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']