def query_perfectly_matched(self, pair): key = MySQLdb.escape_string(pair.keys()[0]) value = MySQLdb.escape_string(pair[key]) sql = 'select isbn, price, title, author, press, description, cover ' \ 'from book_info ' \ 'where %s="%s"' %(key, value) self.cursor.execute(sql) result_list = self.cursor.fetchall() bookpo_list = [] for result in result_list: bookpo = BookPO() bookpo.set_all(result) bookpo_list.append(bookpo) return bookpo_list
def __parse_book_to_po(self, book): #把Book转化为两个PO实体 #steop1 : book->goods goods = GoodsPO() goods.isbn = book.isbn goods.instant_price = book.instant_price goods.link = book.link goods.platform = book.platform goods.crawling_time = book.crawling_time #step2 : book->bookpo bookpo = BookPO() bookpo.description = book.description bookpo.author = book.author bookpo.isbn = book.isbn bookpo.press = book.press bookpo.title = book.title bookpo.price = book.price bookpo.cover = book.cover return (goods, bookpo)