def get_expiry_dates(expiry_date, card_number):
    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)

        cur.execute(
            "SELECT EXPIRY_DATE FROM CARD_DETAILS WHERE CARD_NUMBER=:card_no AND EXPIRY_DATE=:exp_date",
            {
                "card_no": card_number,
                "exp_date": expiry_date
            })

        list_of_expiry_dates = []

        for x in cur:
            c_obj = Card_Details()
            c_obj.set_expiry_date(x[0])
            list_of_expiry_dates.append(c_obj)

        return list_of_expiry_dates

    finally:
        cur.close()
        con.commit()
        con.close()
示例#2
0
def perform_transfer(debit_account,credit_account,transfer_amount):
    try:
        
        con=DBConnectivity.create_connection()
        cur1=DBConnectivity.create_cursor(con)
        cur1.execute("update account set amount=amount-(:transfer_amount) where account_number=:debit_account",
                    {"debit_account":debit_account,"transfer_amount":transfer_amount})
        cur1.execute("update account set amount=amount+(:transfer_amount) where account_number=:credit_account",
                    {"credit_account":credit_account,"transfer_amount":transfer_amount})
        
        
        
        cur1.execute("select count(Transaction_id)  from transactions ")
        a=cur1.fetchall()
        print(a)
        f=0
        
        if ( a[0][0] )!=0:
            cur1.execute("select max(transaction_id)  from transactions")
            b=cur1.fetchall()
            c=(int(b[0][0])+int(1) )
            cur1.execute("insert into transactions values("+str(c)+","+debit_account+","+credit_account+",to_date('"+DateUtility.get_todays_date()+"','DD-mm-yyyy') ,"+transfer_amount+")")
            f=c
        else:
            print(DateUtility.get_todays_date())
            cur1.execute("insert into transactions values(1,"+debit_account+","+credit_account+",to_date('"+DateUtility.get_todays_date()+"','DD-mm-yyyy'),"+transfer_amount+")")
            f=1
            
    except Exception as e:
        print(e)
    finally:
        cur1.close()
        con.commit()
        con.close()
    return f
def transaction(list_of_details, amount):
    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)

        card_number = list_of_details[0].get_card_number()
        balance = list_of_details[0].get_balance()
        amount = float(amount)

        if balance < amount:
            return False

        balance -= amount
        cur.execute(
            "UPDATE CARD_DETAILS SET BALANCE=:bal WHERE CARD_NUMBER=:card_no",
            {
                "bal": balance,
                "card_no": card_number
            })

        return True

    finally:
        cur.close()
        con.commit()
        con.close()
def get_customer_name(customer_name, card_number):
    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)

        cur.execute(
            "SELECT CUST_NAME FROM CARD_DETAILS WHERE CARD_NUMBER=:card_no AND UPPER(CUST_NAME)=:cust_name",
            {
                "card_no": card_number,
                "cust_name": customer_name.upper()
            })

        list_of_customer_names = []

        for x in cur:
            c_obj = Card_Details()
            c_obj.set_cust_name(x[0])
            list_of_customer_names.append(c_obj)

        return list_of_customer_names

    finally:
        cur.close()
        con.commit()
        con.close()
def get_details(phone_no, acct_no):
    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)

        cur.execute(
            "SELECT * FROM CUSTOMER_DTH WHERE PHONE_NO=:ph_no OR ACCOUNT_ID=:acc_no",
            {
                "ph_no": phone_no,
                "acc_no": acct_no.upper()
            })

        list_of_details = []

        for account_id, dth_balance, due_date, phone_no, op_id in cur:
            customer_obj = Customer_DTH()
            customer_obj.set_account_id(account_id)
            customer_obj.set_dth_balance(dth_balance)
            dd = str(due_date)
            customer_obj.set_due_date(dd[:10])
            customer_obj.set_phone_no(phone_no)
            customer_obj.set_op_id(op_id)

            list_of_details.append(customer_obj)
        return list_of_details

    finally:
        cur.close()
        con.commit()
        con.close()
def get_RMN(phone_no, operator_id):
    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)

        cur.execute(
            "SELECT PHONE_NO FROM CUSTOMER_DTH WHERE PHONE_NO=:ph_no AND OP_ID=:op_id",
            {
                "ph_no": phone_no,
                "op_id": operator_id.upper()
            })

        list_of_phone_numbers = []

        for rmn in cur:
            rmn_obj = Customer_DTH()
            rmn_obj.set_phone_no(rmn[0])
            list_of_phone_numbers.append(rmn_obj)

        return list_of_phone_numbers

    finally:
        cur.close()
        con.commit()
        con.close()
示例#7
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()
示例#8
0
def get_selected_food_items_present(selected_food_items,restaurant_name) :
    try:
#         print("//////////////////def get_selected_food_items_present/////////////////////")
#         print()
        con=DBConnectivity.create_connection()
        cur=DBConnectivity.create_cursor(con)
        list_of_selected_food_items_present=[]
        #restaurant_name = FoodModule.Food.restaurant_name
#         print("restaurant_name")
#         print(restaurant_name)
        for food_items in selected_food_items :
            cur2=DBConnectivity.create_cursor(con)
            cur2.execute("select foodname from fooditem where foodname =:food_n and restaurant_name =:restaurant_n" , {"food_n" :food_items, "restaurant_n" : restaurant_name})
            
            for val in cur2 :
                print(val)
                list_of_selected_food_items_present.append(val[0])

        
#         print("After execute")
#         print("list_of_selected_food_items_present")
#         print(list_of_selected_food_items_present)
        return list_of_selected_food_items_present
        
        
    finally :
        cur.close()
        con.close()
示例#9
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()
示例#10
0
def get_package_detail(cust_id, current_operator):
    if (cust_id.isalpha()):
        raise InvalidDTHOperatorException()

    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)
        cur.execute(
            "select * from DTHUser  where CustId=:CustId and Operator=:Operator",
            {
                "CustId": cust_id,
                "Operator": current_operator
            })
        data = cur.fetchall()
        if (len(data) == 0):
            raise InvalidDTHOperatorException()
        else:
            return data

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

    #except InvalidMobileNumberException as e:
    #print(e)


#check_mobile_operator(9040)
#validate_dth_operator('SMP')
#get_package_detail(1)
示例#11
0
def new_pwd(user, mob_no):
    try:
        con = DBConnectivity.create_connection()
        cur3 = DBConnectivity.create_cursor(con)
        list_of_passwords = []
        cur3.execute("select * from pwd_check where mob_no=" + str(mob_no))
        for row in cur3:
            pwd1 = row[1]
            pwd2 = row[2]
            pwd3 = row[3]
            list_of_passwords.append(pwd1)
            list_of_passwords.append(pwd2)
            list_of_passwords.append(pwd3)
        #print(list_of_passwords)
        if (user.get_pwd() in list_of_passwords):
            print("your password can not be previous 3 passwords")
        else:
            update_pwd_check = viewDB.update_password_check(
                user, list_of_passwords, mob_no)
            update_pwd = viewDB.update_password(user, mob_no)
            if (update_pwd == True):
                return True
            else:
                return False
    finally:
        cur3.close()
        con.close()
示例#12
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()  
        
              
        
                       
               
                        
        
             
                
                
        
        
示例#13
0
def db_updating_transection_table():
    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)
        cur.execute(
            "select order_count from User_Transactions where username = :username",
            {"username": this_username})
        for i in cur:
            user_count = i[0]
        user_count += 1
        cur.execute(
            "update User_Transactions set order_count = :user_count where username = :username",
            {
                "username": this_username,
                "user_count": user_count
            })

        cur.execute(
            "select overall_total_price from User_Transactions where username = :username",
            {"username": this_username})
        for j in cur:
            overall_total_price = j[0]
        overall_total_price += Billing.total_charge
        cur.execute(
            "update User_Transactions set overall_total_price = :overall_total_price where username = :username",
            {
                "username": this_username,
                "overall_total_price": overall_total_price
            })

    finally:
        con.commit()
        cur.close()
        con.close()
示例#14
0
def get_categories_fooditems(restaurant_name , category_name) :
    try:
#         print("////////////////def get_categories_fooditems///////////////////////")
#         print()
        con=DBConnectivity.create_connection()
        cur=DBConnectivity.create_cursor(con)
        list_of_restaurants_fooditems=[]
        #print(restaurant_name)
        cur.execute("select foodname , price , availability from fooditem where restaurant_name =:restaurant_n and category_name =:category_n",{"restaurant_n":restaurant_name, "category_n":category_name})
        
        #print("After execute")
        for  foodName, price, availability in cur:
            
            '''
            In this loop, we are creating a ItemModule3 object for every row
            and setting the values from the row into the CategoryItems object
            '''
            ItemModule3=CategoryItems()
            ItemModule3.set_food_name(foodName)
            ItemModule3.set_price(price)
            ItemModule3.set_availability(availability)

            '''
            Here were are adding the FoodItems to a list
            '''
            list_of_restaurants_fooditems.append(ItemModule3)   

        return list_of_restaurants_fooditems

    finally :
        cur.close()
        con.close()
示例#15
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()
示例#16
0
def get_food_items_availability(selected_food_items,restaurant_name) :
    try:
#         print("//////////////////def get_food_items_availability/////////////////////")
#         print()
        con=DBConnectivity.create_connection()
        cur=DBConnectivity.create_cursor(con)
        list_of_food_items_availability=[]
        #restaurant_name = FoodModule.Food.restaurant_name

        for food_items in selected_food_items :
            #print(food_items)
            cur2=DBConnectivity.create_cursor(con)
            cur2.execute("select availability from fooditem where foodname =:food_n and restaurant_name =:restaurant_n" , {"food_n" :food_items, "restaurant_n" : restaurant_name})

            for val in cur2 :
                list_of_food_items_availability.append(val[0])

        
#         print("After execute")
#         print("list_of_food_items_availability")
#         print(list_of_food_items_availability)

        return list_of_food_items_availability
        

    finally :
        cur.close()
        con.close()
示例#17
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()
示例#18
0
def checkchat_DB(obj):
    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)
        cur.execute(
            "select count(*) from chatlog where sender=:mob_sender or receiver=:mob_receiver",
            {
                "mob_sender": obj.get_mobile_number(),
                "mob_receiver": obj.get_mobile_number()
            })
        for row in cur:
            count = row[0]
        contactlist = []
        if (count != 0):
            cur.execute(
                "select sender from chatlog where receiver=:mob_receiver union select receiver from chatlog where sender=:mob_sender",
                {
                    "mob_sender": obj.get_mobile_number(),
                    "mob_receiver": obj.get_mobile_number()
                })
            for row in cur:
                contactlist.append(row[0])
    finally:
        cur.close()
        con.close()
        return contactlist
def get_details(card_number):
    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)

        cur.execute("SELECT * FROM CARD_DETAILS WHERE CARD_NUMBER=:card_no",
                    {"card_no": card_number})

        list_of_details = []

        for a, b, c, d, e, f, g, h in cur:
            c_obj = Card_Details()
            c_obj.set_card_number(a)
            c_obj.set_cust_name(b)
            c_obj.set_expiry_date(c)
            c_obj.set_cvv(d)
            c_obj.set_card_type(e)
            c_obj.set_status(f)
            c_obj.set_balance(g)
            c_obj.set_grid_code(h)

            list_of_details.append(c_obj)

        return list_of_details

    finally:
        cur.close()
        con.commit()
        con.close()
示例#20
0
def get_values(sources, destinations, depttimes):
    '''Returns list containing flights detail having matched conditions'''
    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)
        list_of_flights = []
        cur.execute(
            "select * from flight where Lower(destination) =: destinations and Lower(source) =: sources and Lower(depttime) >: depttimes",
            {
                "destinations": destinations,
                "sources": sources,
                "depttimes": depttimes
            })
        for row in cur:
            flight = Flight(row[0], row[1], row[5], row[6], row[7])
            list_of_flights.append(flight)
        return list_of_flights

    except Exception as e:
        print("Sorry some system error occurred")
        print(e)

    finally:
        cur.close()
        con.close()
def get_Account_ID(acct_id, operator_id):
    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)

        cur.execute(
            "SELECT ACCOUNT_ID FROM CUSTOMER_DTH WHERE ACCOUNT_ID=:acc_id AND OP_ID=:op_id",
            {
                "acc_id": acct_id.upper(),
                "op_id": operator_id.upper()
            })

        list_of_account_ids = []

        for a_id in cur:
            customer_obj = Customer_DTH()
            customer_obj.set_account_id(a_id[0])
            list_of_account_ids.append(customer_obj)

        return list_of_account_ids

    finally:
        cur.close()
        con.commit()
        con.close()
示例#22
0
def check_flight(p_flightid,date_of_travel,p_no_of_children,p_no_of_adults,primary_passenger):
    try:
        
        con=DBConnectivity.create_connection()
        cur=DBConnectivity.create_cursor(con)
        flag=0
        cur.execute("select adultfare,childfare from flight_details where flightid=:flight_id",{"flight_id":p_flightid})
        
        for row in cur:
            flag=1;
            if row[0]==None:
                raise InvalidFlightIdException()
            else:
                if(validate_date(date_of_travel)): 
                    if(int(p_no_of_children)>=0 and int(p_no_of_children)<=4):
                        if(int(p_no_of_adults)>=1 and int(p_no_of_adults)<=4):
                            if(primary_passenger!=""):   
                                fare=row[0]*int(p_no_of_adults)
                                fare+=row[1]*int(p_no_of_children)
                                return fare
                            else:
                                raise InvalidPrimaryPassenger()
                        else:
                            raise InvalidAdultsException()
                    else:
                        raise InvalidChildrenException()
                else:
                    raise InvalidDateException()
        if(flag==0):
            raise InvalidFlightIdException()
    finally:
        cur.close()
        con.close()
示例#23
0
def get_phonenoinoperator(phone_no, operator):
    try:
        op = operator.upper()
        opid = ""
        count = []
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)
        cur2 = DBConnectivity.create_cursor(con)
        cur.execute(
            "select op_id from operator where upper(op_name)=:op_name and upper(op_id) like 'M%'",
            {"op_name": op.upper()})
        for cid in cur:

            opid = cid[0]

            cur2.execute(
                "select phone_no from customer_mobile where op_id=:op_id and phone_no=:pho",
                {
                    "op_id": opid.upper(),
                    "pho": phone_no
                })
            for ph in cur2:
                phone = customer_mobile()
                phone.set_phone_no(ph)
                count.append(phone)

        if (len(count) != 0):
            return count
        return False

    finally:
        cur.close()
        cur2.close()
        con.commit()
        con.close()
示例#24
0
def checkout_Yes(username):

    #Dictionary
    print("FoodName  \t Quantity")
    for index, value in FoodModule.Food.cart_dict.items():
        print(index, " \t \t ", value)
    is_registered_user_flag = FoodModule.Food.is_registered_user

    if is_registered_user_flag == False:
        print("Guest User Logging in")
        FoodModule.Food.registered_user = '******'

    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)
        username = FoodModule.Food.registered_user
        '''
        SQL statement which is to be executed using bind variables
        #insert into checkoutcart(username ,foodname , quantity) values ('Kautilya','Masala', 200);
        '''
        is_cart_saved = FoodModule.Food.is_cart_saved
        #         print(username)
        #         print("is_cart_saved")
        #         print(is_cart_saved)
        if is_cart_saved:
            #print("In  if is_cart_saved  ")

            cur.execute("delete from checkoutcart where username =:user_n",
                        {"user_n": username})

            FoodModule.Food.is_cart_saved = False

        if FoodModule.Food.is_cart_saved == False:
            #print("In  if is_cart_saved  == False ")
            for index, value in FoodModule.Food.cart_dict.items():
                cur.execute(
                    "insert into checkoutcart(username ,foodname , quantity) values (:user_n, :food_n , :qty_ord)",
                    {
                        "user_n": username,
                        "food_n": index,
                        "qty_ord": value
                    })

            #Saving the flag for Direct Module 4 execution that The cart is been saved once for this registered user
            FoodModule.Food.is_cart_saved = True

    finally:
        '''
        Remove the print statement
        '''
        #print("Closing the cursor & connections in def checkout_Yes(username):")

        FoodModule.Food.cart_dict.clear()
        cur.close()
        con.commit()
        con.close()
    '''
    #Call Module 4 Billing
    '''
    ViewFunctionsBilling.start_billing()
示例#25
0
def set_restaurant_attributes(temp_rest, id):

    try:

        con = DBConnectivity.create_connection()

        cur = DBConnectivity.create_cursor(con)

        cur.execute(
            "select id, name, area, pincode, contactno from restaurant where id=:id",
            {"id": id})

        for id, name, area, pincode, contactno in cur:

            temp_rest.set_contact_no(contactno)

            temp_rest.set_restaurant_id(id)

            temp_rest.set_pincode(pincode)

            temp_rest.set_r_name(name)

            temp_rest.set_area(area)

        return 1

    except:

        return -1

    finally:

        cur.close()

        con.close()
示例#26
0
def get_products(category):
    try:
        con=DBConnectivity.create_connection()
        cur=DBConnectivity.create_cursor(con)
        list_of_products=[]
        cur.execute("select productid, productname, price from sample_product where category=:category",{"category":category})
        for product_id,name,price in cur:
            '''
            In this loop, we are creating a product object for every row
            and setting the values from the row into the product object
            '''
            product=Product()
            product.set_price(price)
            product.get_price
            
         
                            
            product.set_product_id(product_id)
            product.set_product_name(name)
            
            '''
            Here were are adding the product to a list
            '''
            list_of_products.append(product)
            
        return list_of_products
        
    finally:
        cur.close()
        con.close()
def insert_booking(flightid, dateoftravel, passengername, noofchild,
                   noofadults, totalfare):
    '''calculates booking id and insert values in bookedflight table'''
    try:
        count = 1
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)
        cur2 = DBConnectivity.create_cursor(con)
        cur2.execute("select * from bookedflight")
        for row in cur2:
            count += 1
        bookingid = count
        cur.execute(
            "insert into bookedflight values(:bookingid,:flightid,to_date(:dateoftravel,'dd-mm-yy'),:passengername,:noofchild,:noofadults,:totalfare)",
            {
                "bookingid": bookingid,
                "flightid": flightid,
                "dateoftravel": dateoftravel,
                "passengername": passengername,
                "noofchild": noofchild,
                "noofadults": noofadults,
                "totalfare": totalfare
            })
        con.commit()
        return bookingid

    except Exception as e:
        print("Sorry some system error occurred")
        print(e)

    finally:
        cur.close()
        con.close()
示例#28
0
def validate_pincode(pincode):

    try:

        con = DBConnectivity.create_connection()

        cur = DBConnectivity.create_cursor(con)

        cur.execute("select id from restaurant where pincode like (" +
                    pincode[:4] + "%)")

        count = 0

        for row in cur:

            count += 1

        if count >= 1:

            return 1

        return 0

    except:

        return -1

    finally:

        cur.close()

        con.close()
示例#29
0
def login(username, password):
    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)
        cur.execute(
            "select username,password,cityname,area from registration where username=:category1 and password=:category2",
            {
                "category1": username,
                "category2": password
            })
        for username, password, cityname, area in cur:
            '''
            In this loop, we are creating a registration object for every row
            and setting the values from the row into the registration object
            '''
            customer = Customer()
            customer.set_username(username)
            customer.set_password(password)
            customer.set_city(cityname)
            customer.set_area(area)
            '''
            Here were are adding the new registration to a list
            '''
            return customer

    finally:
        cur.close()
        con.close()
示例#30
0
def display_most_ordered_transactions_user():
    print("In Function display_most_ordered_transactions_user")

    try:
        con = DBConnectivity.create_connection()
        cur = DBConnectivity.create_cursor(con)
        max_transact_user = ""
        '''User Query
        #select username from User_Transactions where order_count = ( select max(order_count) from User_Transactions);
        '''

        cur.execute(
            "select username from User_Transactions where order_count = ( select max(order_count) from User_Transactions)"
        )

        for username in cur:
            #print(username)
            max_transact_user = username[0]

        return max_transact_user

    finally:
        print(
            "Closing the cursor & connections in (def display_most_ordered_transactions_user)"
        )
        cur.close()
        con.close()
示例#31
0
def language(mdate,language):
    con=DBConnectivity.create_connection()
    cur=DBConnectivity.create_cursor(con)
    cur.execute("select language from BookMovie where dateofmovie=:date1",{"date1":mdate})
    l=[]
    for row in cur:
        l.append(row[0].lower())
    return l
示例#32
0
def bookHotel(booking):
    try:
        con=DBConnectivity.create_connection()
        cur=DBConnectivity.create_cursor(con)
        cur.execute("insert into hotel_booking values(:bookingid,:hotelid,:flightid,:stayduration,:totalfare,:noofchildren,:noofadults,:eroom,:droom,:primarypassenger)",{"bookingid":booking.get_bookingid(),"hotelid":booking.get_hotel_id(),"flightid":booking.get_flight_id(),"stayduration":booking.get_days_of_stay(),"totalfare":booking.get_fare(),"noofchildren":booking.get_no_of_children(),"noofadults":booking.get_no_of_adults(),"eroom":booking.get_eroom(),"droom":booking.get_droom(),"primarypassenger":booking.get_primary_passenger()})
        con.commit()
    finally:
        cur.close()
        con.close()  
示例#33
0
def bookFlight(booking):
    try:
        con=DBConnectivity.create_connection()
        cur=DBConnectivity.create_cursor(con)
        cur.execute("insert into flight_booking values(:bookingid,:flightid,:totalfare,:primarypassenger,:noofchildren,:noofadults,:dateoftravel)",{"bookingid":booking.get_bookingid(),"flightid":booking.get_flight_id(),"totalfare":booking.get_fare(),"primarypassenger":booking.get_primary_passenger(),"noofchildren":booking.get_no_of_children(),"noofadults": booking.get_no_of_adults(),"dateoftravel":booking.get_date_of_travel()})
        con.commit()
    finally:
        cur.close()
        con.close()
示例#34
0
def retrieve_count():
    try:
        con=DBConnectivity.create_connection()
        cur=DBConnectivity.create_cursor(con)
        cur.execute("select count(*) from flight_booking")
        for row in cur:
            return row[0];
    finally:
        cur.close()
        con.close()
示例#35
0
def get_booked_flight(fbookid):
    try:
        con=DBConnectivity.create_connection()
        cur=DBConnectivity.create_cursor(con)
        list_of_members=[]
        cur.execute("select no_of_children,no_of_adults from flight_booking where bookingid=:fbookid",{"fbookid":fbookid})
        for booking in cur:
            list_of_members.append(booking[0])
            list_of_members.append(booking[1])
        return list_of_members
    finally:
        cur.close()
        con.close() 
def cancelHBooking(hbookingid):
    try:
        con=DBConnectivity.create_connection()
        cur=DBConnectivity.create_cursor(con)
        cur.execute("delete from hotel_booking where hotel_bookingid=:h_bookingid",{"h_bookingid":hbookingid})
        if(cur.rowcount==0):
            raise InvalidHotelBookingIdException()
        else:
            return True
    except InvalidFlightBookingIdException as e:
        print(e)
    except DatabaseError as e:
        print("Can not cancel the hotel booking")
    except Exception as e:
        print("Can not cancel hotel booking")
    finally:
        con.close()
        cur.close()
def get_flight_with1Hop(p_source,p_destination):
    try: 
        flag=0
        con=DBConnectivity.create_connection()
        cur=DBConnectivity.create_cursor(con)
        cur.execute("select t1.flightid,t1.flightname,t1.source,t1.destination,t1.departuretime,t1.arrivaltime,t2.flightid,t2.flightname,t2.source,t2.destination,t2.departuretime,t2.arrivaltime from flight_details t1,flight_details t2 where t1.destination=t2.source and t1.source=:source and t2.destination=:destination",{"source":p_source,"destination":p_destination})
        for row in cur:
            flag=1
            arr1=row[5]
            dep2=row[10]
            if(validate_timing(arr1,dep2)):
                print_flight(row,1)
        if(flag==1):
            return True
        else:
            return False
    finally:
        cur.close()
        con.close()
def cancelFBooking(fbookingid):
    try:
        con=DBConnectivity.create_connection()
        cur=DBConnectivity.create_cursor(con)
        cur.execute("delete from flight_booking where bookingid=:f_bookingid",{"f_bookingid":fbookingid})
        if(cur.rowcount==0):
            raise InvalidFlightBookingIdException()
        else:
            return True
    except InvalidFlightBookingIdException as e:
        print(e)
    except DatabaseError as e:
        print("Cancel you Hotel Booking first")
    except InterfaceError as e:
        print("Cancel you Hotel Booking first")
    except Exception as e:
        print("Cancel you Hotel Booking first")
    finally:
        con.close()
        cur.close()
示例#39
0
def check_hotel(p_hotelid,eroom,droom,days_of_stay,booking_name,children,adult):
    try:
        totalfare=0
        con=DBConnectivity.create_connection()
        cur=DBConnectivity.create_cursor(con)
        cur.execute("select efare,dfare from hotel where hotelid=:hotel_id",{"hotel_id":p_hotelid})
        flag=0
        check =False
        for row in cur:
            flag=1
            if(row[0]==None):
                raise InvalidHotelIdException();
            else:
                check=hotel_validation.validate_member(eroom,adult)
                if(check):
                    raise InvalidAdultExecutiveRoomsException()
                check=hotel_validation.validate_room_members(eroom,droom,children,adult);
                if(check):
                    raise InvalidNoOfRoomsException()
                check=hotel_validation.validate_days_of_stay(days_of_stay)
                if(check):
                    raise InvalidDaysOfStayException()
                check=hotel_validation.validate_booking_name(booking_name)
                if(check):
                    raise InvalidBookingNameException()
                hotel_validation.validate_no_of_children(children)
                hotel_validation.validate_no_of_adult(adult)
                if(booking_name==""):
                    raise InvalidBookingNameException()
                totalfare=(row[0]*eroom+row[1]*droom)*days_of_stay
                return totalfare
        if(flag==0):
            raise InvalidHotelIdException()
        
        for row in cur:
            totalfare=(row[0]*eroom+row[1]*droom)*days_of_stay
            return totalfare
    finally:
        cur.close()
        con.close()
示例#40
0
def get_hotels(location):
    try:
        con=DBConnectivity.create_connection()
        cur=DBConnectivity.create_cursor(con)
        list_of_hotels=[]
        cur.execute("select hotelid, hotelname, location, efare, dfare from hotel where location=:location",{"location":location})
        for hotelid,hotelname,location,efare,dfare in cur:
            '''
            In this loop, we are creating a product object for every row
            and setting the values from the row into the product object
            '''
            hotel=Hotel()
            hotel.set_hotelid(hotelid)
            hotel.set_hotelname(hotelname)
            hotel.set_location(location)
            hotel.set_efare(efare)
            hotel.set_dfare(dfare)
            list_of_hotels.append(hotel)
        return list_of_hotels
        
    finally:
        cur.close()
        con.close()