def populate_transactions_table(self, cursor, number_of_transactions=100_000): '''Populates the transactions table in main.db (needs to already exist) with the amount of transactions specified in the input arg. Expects a DataBaseConnection object to be passed in as first arg ''' user_ids = database.query_user_ids_from_user_table(cursor) product_ids = database.query_product_ids_from_product_table(cursor) for _ in range(number_of_transactions): chosen_product_ids = self._generate_random_chosen_product_ids( product_ids) # print(chosen_product_ids) transaction_data = self._generate_random_transaction_data(user_ids) database.add_transaction(cursor, transaction_data, chosen_product_ids)
def add_transaction(cursor, user_email, chosen_product_ids): '''Adds a new transaction containing the passed product ids for specified user. As this is a verified database call, a valid session id needs to be passed in (see decorator def) in order for the database request to succeed. ''' user_id = database.query_user_id_from_user_email(cursor, user_email) date = util.get_current_date() transaction_data = [user_id, date] return database.add_transaction(cursor, transaction_data, chosen_product_ids)
def add_transaction_to_database(transaction_hash): database.add_transaction(transaction_hash, Blockchain.MULTICHAIN)
def add_transaction_to_database(transaction_hash): database.add_transaction(transaction_hash, Blockchain.BITCOIN)
def find_match(t, sender): cycle = matching.compute_match(sender['id']) if cycle: transaction_id, desc = db.add_transaction(t, sender, cycle) return nlg.new_trade(t, transaction_id, desc) return []
def add_transaction_to_database(transaction_hash): database.add_transaction(transaction_hash, Blockchain.ETHEREUM)