Beispiel #1
0
def search_as_all(city, area, rating_lower, rating_upper, var1):
    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)
        list_of_restaurants = []

        cur.execute(
            "select restaurantname,type_of_food,likes,dislikes,rating from restaurants where city=:category4 and area=:category5 and type_of_food like :category and rating between :category2 and :category3 order by likes desc,dislikes asc",
            {
                "category": '%' + var1 + '%',
                "category2": rating_lower,
                "category3": rating_upper,
                "category4": city,
                "category5": area
            })

        for restaurantname, type_of_food, likes, dislikes, rating in cur:

            select = Select()
            select.set_restaurantname(restaurantname)
            select.set_type_of_food(type_of_food)
            select.set_likes(likes)
            select.set_dislikes(dislikes)
            select.set_rating(rating)

            list_of_restaurants.append(select)
        return list_of_restaurants

    finally:
        cur.close()
        con.close()
Beispiel #2
0
def search_as_likes(city, area):
    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)
        list_of_restaurants = []

        cur.execute(
            "select restaurantname,type_of_food,likes,dislikes,rating from restaurants where city=:category4 and area=:category5 order by likes desc",
            {
                "category4": city,
                "category5": area
            })

        for restaurantname, type_of_food, likes, dislikes, rating in cur:

            select = Select()
            select.set_restaurantname(restaurantname)
            select.set_type_of_food(type_of_food)
            select.set_likes(likes)
            select.set_dislikes(dislikes)
            select.set_rating(rating)

            list_of_restaurants.append(select)

        return list_of_restaurants

    finally:
        cur.close()
        con.close()
Beispiel #3
0
def search_highest_rated():
    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)
        list_of_restaurants = []

        cur.execute(
            "select restaurantname,type_of_food,likes,dislikes,rating from (select restaurantname,type_of_food,likes,dislikes,rating from restaurants order by rating desc) where rownum < 6"
        )

        for restaurantname, type_of_food, likes, dislikes, rating in cur:

            select = Select()
            select.set_restaurantname(restaurantname)
            select.set_type_of_food(type_of_food)
            select.set_likes(likes)
            select.set_dislikes(dislikes)
            select.set_rating(rating)

            list_of_restaurants.append(select)
        return list_of_restaurants

    finally:
        cur.close()
        con.close()