def delete_favourite(user_id, stock_symbol): favourite = db.query(Favourite)\ .filter(Favourite.user_id == user_id)\ .filter(Favourite.stock_symbol == stock_symbol).first() if favourite: db.delete(favourite) return db
def get_favourite(user_id, stock_symbol, favourite_status): favourite = db.query(Favourite)\ .filter(Favourite.user_id == user_id)\ .filter(Favourite.stock_symbol == stock_symbol).first() if favourite: return favourite else: return None
def get_all_favourite(user_id): favourite_list = db.query(Favourite)\ .filter(Favourite.user_id == user_id)\ .filter(Favourite.favourite_status == True) return favourite_list
def get_user(user_id): user = db.query(Portfolio)\ .filter(Portfolio.user_id == user_id)\ .first() return user
def get_all_companies(): stock_companies = db.query(Company).all() return stock_companies
def get_all_price_for_company(symbol): stock_list = db.query(Price)\ .filter(Price.company_symbol == symbol) return stock_list
def get_price(symbol, date_time): price = db.query(Price)\ .filter(Price.company_symbol == symbol)\ .filter(Price.date_time == date_time).first() return price
def get_company(symbol): company = db.query(Company)\ .filter(Company.symbol == symbol).first() return company