def get_all_transactions(self): """ Return all transactions in the database. """ db_result = self.execute(u"SELECT * FROM transactions") return [Transaction.from_database(db_item, self.get_payments(TransactionId(TraderId(bytes(db_item[0])), TransactionNumber(db_item[1])))) for db_item in db_result]
def get_transaction(self, transaction_id): """ Return a transaction with a specific id. """ try: db_result = next(self.execute(u"SELECT * FROM transactions WHERE trader_id = ? AND transaction_number = ?", (database_blob(bytes(transaction_id.trader_id)), text_type(transaction_id.transaction_number)))) except StopIteration: return None return Transaction.from_database(db_result, self.get_payments(transaction_id))