Beispiel #1
0
    def long_haul_flights():

        try:
            mb = databaseconnect.Databases()
            query = "SELECT * FROM Destination WHERE Flight_Type = 'Long-haul';"
            cursor = mb.create_cursor()
            rows = cursor.execute(query)
            for row in rows:
                print(row)
            # a = []
            # for row in rows:
            #     a.append(row)
            # df = pd.DataFrame()
            # df['Short Haul Flights']
            # print(df)
        except Exception:
            print("Server is down. Please try reconnecting")
        # else:
        #     dd = FlightDetails()
        #     dd.list_all_destinations()


# ft = FlightType()
# ft.short_haul_flights()
# ft.long_haul_flights()
    def choose_destination(row):
        fd1 = FlightDetails
        bm = Bookingapp
        choosing = False
        mb = databaseconnect.Databases()
        cursor = mb.create_cursor()

        while not choosing:
            try:
                # from Destinations.citiestoDatabase import DummyCities
                # dc = DummyCities
                # dc.checking_city_exists()
                cursor.execute("SELECT * FROM Destination")
                dt = cursor.fetchall()
                for dt in dt:
                    print(dt)
                das = input("Please enter a DestinationID:\n")

                cursor.execute(
                    "SELECT d.Destination_ID, d.Country, d.City, d.Flight_Price, "
                    "d.Flight_Type, a.Flight_Number "
                    "FROM Destination d JOIN Airplane a on a.Destination_ID = d.Destination_ID "
                    "WHERE d.Destination_ID = ?", [das])

                dest = cursor.fetchone()
                dest_l = list(dest)
                row_l = list(row)
                print(dest_l)
                print(row_l)

                query = f"""
                INSERT INTO Booking_Details(Booking_ID, Flight_Number, PassengersID, Destination_ID, Flight_Price)
                    Values('{row_l[4]}' , '{dest_l[5]}', '{row_l[0]}', '{dest_l[0]}', '{dest_l[3]}')"""
                cursor.execute(query)
                cursor.commit()

                cursor.execute('SELECT * FROM Booking_Details')
                rob = cursor.fetchall()
                print(rob)

                #
                # FlightDetails.sql_to_csv(dest)
                user_input = input(
                    "\n\nType [M] to return to the menu\n\nYour selection: \n")

            except Exception:
                print(
                    "Invalid selection. Please type [M] to return to the menu")
            if user_input.upper() == "Y":
                return bm.userStore()
                choosing = True
            elif user_input.upper() == "M":
                print(fd1.menu())
                choosing = True
            else:
                print("Invalid selection. Please type in [Y] or [M]")
 def get_attendee_list():
     mb = databaseconnect.Databases()
     cursor = mb.create_cursor()
     get_passenger_list = input(
         "Type in Destination E.G Rome to retrieve "
         "full passenger list for a flight:\n").capitalize()
     cursor.execute(
         "SELECT p.First_name, p.PassengersID,d.City FROM Passengers p JOIN Booking_Details bd on "
         "bd.PassengersID = p.PassengersID JOIN "
         "Destination d on bd.Destination_ID = d.Destination_ID WHERE d.City = ?",
         [get_passenger_list])
     row = cursor.fetchmany(10)
     # FlightDetails.choose_destination(row)
     print(row)
Beispiel #4
0
 def short_haul_flights():
     # print("\nShort Haul Flights unavailable. Server is down")
     try:
         mb = databaseconnect.Databases()
         query = "SELECT * FROM Destination WHERE Flight_Type = 'Short-haul';"
         cursor = mb.create_cursor()
         rows = cursor.execute(query)
         for row in rows:
             print(row)
         # a = []
         # for row in rows:
         #     a.append(row)
         # df = pd.DataFrame()
         # # df['Short Haul Flights']
         # print(df)
     except Exception:
         print("Server is down. Please try reconnecting")
    def make_booking():
        mb = databaseconnect.Databases()
        cursor = mb.create_cursor()

        make_booking_loop = True

        while make_booking_loop:
            try:
                passenger_ID = input("Input passenger ID:\n")
                cursor.execute(
                    "SELECT * FROM Passengers WHERE PassengersID = ?",
                    [passenger_ID])
                row = cursor.fetchone()
                print(row)
                FlightDetails.choose_destination(row)
                break

            except Exception:
                print(
                    "Invalid passenger ID,\nInput a correct Passenger ID: \n")