Example #1
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()
Example #2
0
def hotel_name(city, area, restaurant_name):
    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)
        list_of_restaurants = []

        cur.execute(
            "select restaurantname from restaurants where city=:category4 and area=:category5 and restaurantname=:category",
            {
                "category": restaurant_name,
                "category4": city,
                "category5": area
            })

        for restaurantname in cur:

            select = Select()
            select.set_restaurantname(restaurantname)

            list_of_restaurants.append(select)
        return list_of_restaurants

    finally:
        cur.close()
        con.close()
Example #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()
Example #4
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()
Example #5
0
def city_wise_highest_booked(city):
    try:
        con=DBConnectivity.create_connection()
        cur=DBConnectivity.create_cursor(con)
        list_of_restaurants=[]
        
        cur.execute("select t.restaurantname, t.city, t.area, t.rating from restaurants t WHERE T.CITY =:category AND t.rating in(select max(u.rating) from restaurants u where u.city =:category group by u.city)",{"category":city})
        
        for restaurantname,city,area,rating in cur:
            
                select=Select()
                select.set_restaurantname(restaurantname)
                select.set_city(city)
                select.set_area(area)
                
                select.set_rating(rating)
            
                list_of_restaurants.append(select)   
        return list_of_restaurants
    
    finally:
       cur.close()
       con.close()