def get_all_food():
     session = make_session()
     # query FoodDictionary to fetch all rows
     data = session.query(FoodDictionary) \
         .with_entities(FoodDictionary.foodName, FoodDictionary.calories).all()
     session.close()
     return data
    def get_all_exercises(self):
        session = make_session()
        data = session.query(ExerciseDictionary) \
            .with_entities(ExerciseDictionary.specificMotion, ExerciseDictionary.metValue).all()

        session.close()
        return data
 def addFood(foodName, calories):
     session = make_session()
     print(foodName)
     print(calories)
     addFood = FoodDictionary(foodName=foodName, calories=float(calories))
     session.add(addFood)
     session.commit()
     session.close()
 def addExercise(activity, specificMotion, metValue):
     session = make_session()
     addExercise = ExerciseDictionary(activity=activity,
                                      specificMotion=specificMotion,
                                      metValue=metValue)
     session.add(addExercise)
     session.commit()
     session.close()
 def getFoodId(self, foodName):
     session = make_session()
     food = session.query(FoodDictionary)
     return food
 def get(self, index):
     session = make_session()
     food = session.query(FoodDictionary).get(index)  # for an index in table, query correspoding baseCalorie
     session.close()
     return food