def flightScheduleFunction(): os.system("cls"); print('\033[1;36;40m\nFLIGHT SCHEDULE MENU: \033[m') flight_number = 0; while True: flight_number = int(input("Flight number (NNNN): ")); if len(str(flight_number)) == 4: databaseconnection.getFlightSchedule(flight_number) # After run the function, the user has the option to continue or exit; while True: print("1 - Main menu\n2 - Exit") opt = str(input("Option: ")) if (opt == "1" or opt == "2"): if (opt == "1"): print("Returning to main menu!"); sleep(3) systemmain.system(); elif (opt == "2"): print("Thank you for your presence with us!"); sleep(3); break; break; else: print("Please, you need insert a valid option! Try again.") break; else: print("Please, you need insert a valid flight number! Try again.")
def exitSystemFunction(): os.system("cls") while True: print("EXIT") print('Are you sure? ') print('1 - Yes') print('2 - Not') userExitOption = str(input('Option: ')) if ("1" <= userExitOption <= "2"): if (userExitOption == "1"): print("Thank you for your presence with us!") break; else: systemmain.system(); break; else: print("Please, you need insert a valid option! Try again.")
def exitOrNotFunction(): # After run the function, the user has the option to continue or exit; while True: print("1 - Main menu\n2 - Exit") opt = str(input("Option: ")) if (opt == "1" or opt == "2"): if (opt == "1"): print("Returning to main menu!"); sleep(3) systemmain.system(); elif (opt == "2"): print("Thank you for your presence with us!"); sleep(3); break; break; else: print("Please, you need insert a valid option! Try again.")
def flightDetailsFunction(): os.system("cls") print('FLIGHT DETAILS MENU') print("\033[1;35m1 - Add flight") print("2 - Edit flight") print("3 - Delete flight") print("4 - Flight leave and arrive") print("5 - Main menu") print("6 - Exit system\033[m") while True: userOption = str(input("Option: ")) if ("6" < userOption < "1"): print("Please, you need insert a valid option! Try again.") else: if (userOption == "1"): flightFunctions.addNewFlight(); break; elif (userOption == "2"): flightFunctions.editFlight(); break; elif (userOption == "3"): flightFunctions.deleteFlight(); break; elif (userOption == "4"): flightFunctions.flightDepartureAndArrive(); break; elif (userOption == "5"): systemmain.system(); else: exitOrNotFunction() break;
def deleteFlightFromDatabase(ID): print("ACCESSING DATABASE") conn = SQLConn.connect( host = "", user = "", password = "", database = "" ) cur = conn.cursor() sleep(3); print("\n") print("Searching flight ID..."); sleep(3); try: sql = "SELECT * FROM flight_details WHERE flight_id = '(%s)'"; value = (ID); cur.execute(sql, value); print("\033[1;32mThe flight was found!\033[m"); print("\033[1;33m-"*40); print(f"FLIGHT ID {ID}\033[m"); for row in cur: print(row); while True: print("\n") print("This flight will be deleted! Continue?\n1 - Yes\n2 - Not") opt = str(input("Option: ")) if opt == "1" or opt == "2": if opt == "1": print("\n", "-"*40); print("DELETING FLIGHT"); print("-"*40); sleep(1); try: sql = "DELETE FROM flight_details WHERE flight_id = '(%s)'"; value = (ID); cur.execute(sql, value); conn.commit(); print("\n", '\033[1;32m', "-"*40); print("\033[1;32mFLIGHT SECCESSFULY DELETED\033[m"); print("\n", '\033[1;32m', "-"*40); conn.close(); except Exception as exc: print("\033[1;31mERROR trying to delete the flight!\033[m"); print(exc); conn.close(); break; else: print("\n", "-"*40); print("DELETE FLIGHT ABOART"); print("\n", "-"*40); conn.close(); sleep(1); systemmain.system(); break; else: print("Please, you need insert a valid option! Try again."); except Exception as exc: print("\033[1;31mERROR searching the flight! Maybe the flight does not exist!\033[m") print(exc); conn.close();
def addFlightDatabase(flight_id, flight_number, flight_name, flight_origin, flight_destination, flight_departure_time, flight_arrival_time, flight_time, flight_amount, flight_availability): sleep(3); print("\033[1;33m-"*40) print("INFORMATIONS") print("-"*40) print("Flight ID: ", flight_id); sleep(0.5); print("Flight number: ", flight_number); sleep(0.5) print("Flight name: ", flight_name); sleep(0.5); print("Flight origin: ", flight_origin); sleep(0.5); print("Flight destination: ", flight_destination); sleep(0.5); print("Flight time: ", flight_time); sleep(0.5); print("Departure time: ", flight_departure_time); sleep(0.5); print("Arrival time: ", flight_arrival_time); sleep(0.5); print("Flight amount: ", flight_amount); sleep(0.5); print(f"Flight Availabilty: {flight_availability}\033[m"); sleep(0.5); print("ACCESSING DATABASE"); conn = SQLConn.connect( host = "", user = "", password = "", database = "" ) cur = conn.cursor() sleep(3); sql = "INSERT INTO flight_details VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"; try: cur.execute(sql, (flight_id, flight_number, flight_name, flight_origin, flight_destination, flight_departure_time, flight_arrival_time, flight_time, flight_amount, flight_availability)); conn.commit(); print("\n", '\033[1;32m', "-"*40); print("SUCCESSFUL FLIGHT ADDED!\033[m"); print('\033[1;32m', "-"*40); while True: sleep(0.5) print("1 - Exit\n2 - Main menu") opt = str(input("Option: ")) if (opt == "1"): conn.close() print("\033[1;36mThank you for your presence!\033[m") break; elif (opt == "2"): systemmain.system(); else: print("Please, you need insert a valid option! Try again."); except Exception as exc: print("\n", "-"*40); print("\033[1;31mERROR trying to add new flight process!\033[m"); print("-"*40); print(exc); conn.close(); print("\nThe system will reset!")
def insertUserToDatabase(user_id, first_name, second_name, last_name, age, birthday, email_address, country_official_name, country, city, phone, passport, ticket): os.system("cls"); sleep(1); print('\033[1;33;40m') print("-"*40) print("INFORMATIONS") print("-"*40) print("ID: ", user_id) sleep(0.5) print("Name: ", first_name, " ", second_name, " ", last_name) sleep(0.5) print("Age: ", age) sleep(0.5) print("Birthdate: ", birthday) sleep(0.5) print("Email address: ", email_address) sleep(0.5) print("Country: ", country) sleep(0.5) print("Country Official Name: ", country_official_name); sleep(0.5) print("CIty: ", city) sleep(0.5) print("Phone: ", phone) sleep(0.5) print("Passport: ", passport) sleep(0.5) print(f"Ticket: {ticket} \033[m") sleep(0.5) print("-"*40) print("ACCESSING DATABASE") conn = SQLConn.connect( host = "", user = "", password = "", database = "" ) cur = conn.cursor() sleep(3); sql = "INSERT INTO passengers VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" try: cur.execute(sql, (user_id, first_name, second_name, last_name, age, birthday, email_address, country, city, phone, passport, ticket)); conn.commit(); conn.close(); print("\n", "-"*40); print("\033[1;32mSUCCESSFUL REGISTRATION!\033[m"); print("-"*40); sleep(3); while True: os.system("cls"); sleep(0.5); print("1 - Exit\n2 - Main menu") opt = str(input("Option: ")) if (opt == "1"): conn.close() print("\033[1;36mThank you for your presence!\033[m") break; elif (opt == "2"): systemmain.system(); else: print("Please, you need insert a valid option! Try again."); except Exception as exc: print("\n", "-"*40); print("\033[1;31mERROR in the registration process!\033[m"); print("-"*40); print(exc) conn.close(); print("\nThe system will reset!");
# Ambient # Here all the code will be executed from mysql.connector.dbapi import Date from functionspackage import functions from system import systemmain from databasepackage import databaseconnection systemmain.system();