Dec-11-2022, 10:06 PM
You need to call check_price for each product. I would refactor the code, changing check_price() to get_price(), a function that returns the current price for a product.
con = sqlite3.connect(MainDatabase) for product, url, buy_price in con.execute("SELECT Product, URL, Alert_Price FROM AmazonPriceTracker"): current_price = get_price(url) if current_price < float(buy_price): print(f"Buy {product} ${current_price}")