0% found this document useful (0 votes)
12 views6 pages

Flight Booking System Code in Python

Source code for bus pass management system project

Uploaded by

shabnamshahistha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views6 pages

Flight Booking System Code in Python

Source code for bus pass management system project

Uploaded by

shabnamshahistha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import mysql.

connector
from csv import DictWriter
from csv import DictReader
import os

conn = [Link](host='localhost', username='root',password='python',


database='airlines_booking')
my_cursor = [Link]()

print("\n********************WELCOME TO FLIGHT BOOKING


SYSTEM***********************")

acc = input("\nDO YOU HAVE A ACCOUNT (Y/N)")


e = []
if acc=='y' or acc=='yes' or acc=='Y' or acc=='YES':
email = input("\nENTER YOUR EMAIL ID:-")
[Link](email)
pas = input("\nENTER YOUR PASSWORD:-")
otp = int(input("\nENTER A OTP CODE ON YOUR EMAIL AND PHONE NO:-"))

print("\n-------LOGIN SUCCESSFUL-------")

else:
nam = input("\nENTER YOUR FULL NAME:-")
pn = int(input("\nENTER YOUR PHONE NO:-"))
city = input("\nENTER YOUR CITY NAME:-")
state = input("\nENTER YOUR STATE:-")
em = input("\nENTER YOUR EMAIL ID:-")
[Link](em)
passw = input("\nENTER YOUR PASSWORD:-")
print(f"\nOTP SEND TO {pn} AND {em}")
ot = int(input("\nENTER THE OTP NO:-"))

print("\n-------YOUR ACCOUNT IS CREATED SUCCESSFULLY-------")

print("\nhow do you want to search your flight by")


print("[Link] number")
print("[Link]")

ans = int(input("\nAnswer (1/2):-"))

if ans==1:
num = (input("\nENTER FLIGHT NUMBER:-"))
query = "SELECT * FROM FLIGHTS WHERE FLIGHT_NO = '{}' ".format(num)
my_cursor.execute(query)
print("\nYOUR FLIGHT DATA IS-------")
for a in my_cursor:
print(a)

deplo = []
arrlo = []
fli = []

def flight_data():
departure = input("\nENTER YOUR DEPARTURE LOCAION:-")
arrival = input("\nENTER YOUR ARRIVAL LOCATION:-")
query2 = "SELECT AIRLINES_NAME FROM FLIGHTS WHERE DEPARTURE = '{}' AND
DESTINATION = '{}'".format(departure, arrival)
[Link](departure)
[Link](arrival)
my_cursor.execute(query2)
print("\nYOUR REQUIRED FLIGHTS ARE------")
for b in my_cursor:
print(b)
fly = input("\nENTER A FLIGHT NAME YOU WANT:-")
[Link](fly)
print("\nHEAR THE DETAILS OF YOUR FLIGHT--")
query3 = "SELECT * FROM FLIGHTS WHERE AIRLINES_NAME = '{}' AND DEPARTURE = '{}'
AND DESTINATION = '{}' ".format(fly, departure, arrival)
my_cursor.execute(query3)
for c in my_cursor:
return print(c)

if ans==2:
flight_data()

con = input("\nWOULD YOU LIKE TO CONTINUE (Y/N):-")


while True:
if con=='n' or con=='N' or con=='no' or con=='NO':
flight_data()
else:
break

passenger = int(input("\nENTER A NUMBER OF PASSANGERS:-"))

nam=[]
ag=[]
gen=[]

def pass_data():
name = input("\nENTER A NAME OF A PASSENGER:-")
age = int(input(f"\nENTER THE AGE OF {name}:-"))
gender = input("\nMALE/FEMALE:-")
[Link](name)
[Link](age)
[Link](gender)
with open('[Link]', 'a', newline='') as csvfile:
csvwriter = DictWriter(csvfile, fieldnames=['name', 'age', 'gender'])
[Link]()
[Link]({'name':name, 'age':age, 'gender':gender})
return print("\n-------DATA ENTERED SUCCESSFULLY-------")

for d in range(passenger):
pass_data()

def read_csv():
with open('[Link]') as csvreader:
reader = DictReader(csvreader)
for row in reader:
print(row)
[Link](r'[Link]')
return print("------------------------------------")
read_csv()
print("\nCHECK YOUR DETAILS----")

ch = input("\nDO YOU WANT TO CONTINUE (Y/N):-")

while True:
if ch=='n' or ch=='N' or ch=='no' or ch=='NO':
for e in range(passenger):
pass_data()
read_csv()
else:
break

print("\nCHOOSE THE CLASS YOU WANT:-")


print("[Link] CLASS")
print("[Link] CLASS (+20% CHARGES)")
print("[Link] CLASS (+40% CHARGES)")

flo = []
tdep = []
tarr= []

def fl_nm():
query4 = "SELECT FLIGHT_NO FROM FLIGHTS WHERE airlines_name = '{}' and
DEPARTURE = '{}' and DESTINATION = '{}' ".format (fli[0], deplo[0], arrlo[0])
my_cursor.execute(query4)
for f in my_cursor:
[Link](f)

query5 = "SELECT TIME_OF_DEPARTURE FROM FLIGHTS WHERE airlines_name = '{}' and


DEPARTURE = '{}' and DESTINATION = '{}' ".format (fli[0], deplo[0], arrlo[0])
my_cursor.execute(query5)
for g in my_cursor:
[Link](g)

query6 = "SELECT TIME_OF_ARRIVAL FROM FLIGHTS WHERE airlines_name = '{}' and


DEPARTURE = '{}' and DESTINATION = '{}' ".format (fli[0], deplo[0], arrlo[0])
my_cursor.execute(query6)
for h in my_cursor:
[Link](h)

an = []
de = []
ds = []
td = []
ta = []

def fl_no():
query7 = "SELECT AIRLINES_NAME FROM FLIGHTS WHERE FLIGHT_NO = '{}'".format(num)
my_cursor.execute(query7)
for i in my_cursor:
[Link](i)

query8 = "SELECT DEPARTURE FROM FLIGHTS WHERE FLIGHT_NO = '{}'".format(num)


my_cursor.execute(query8)
for j in my_cursor:
[Link](j)

query9 = "SELECT DESTINATION FROM FLIGHTS WHERE FLIGHT_NO = '{}'".format(num)


my_cursor.execute(query9)
for k in my_cursor:
[Link](k)

query10 = "SELECT TIME_OF_DEPARTURE FROM FLIGHTS WHERE FLIGHT_NO =


'{}'".format(num)
my_cursor.execute(query10)
for l in my_cursor:
[Link](l)

query11 = "SELECT TIME_OF_ARRIVAL FROM FLIGHTS WHERE FLIGHT_NO =


'{}'".format(num)
my_cursor.execute(query11)
for m in my_cursor:
[Link](m)

cl = int(input("\nENTER CLASS NO (1/2/3):-"))

payment = []

if ans==1 and cl==1:


fl_no()
query12 = "SELECT CHARGES*{} FROM FLIGHTS WHERE FLIGHT_NO =
'{}'".format(passenger, num)
print(f"\nnames = {nam} age = {ag} gender = {gen}")
print(f"flight name = {an} departure = {de} destination = {ds}")
print(f"flight number = {num} diparture time = {td} arrival time =
{ta} ")
print("class = economy class")
for n in my_cursor:
[Link](n)
print(f"\nYOU HAVE TO PAY {n} RUPEES")

elif ans==1 and cl==2:


fl_no()
query13 = "SELECT (CHARGES +CHARGES*0.2)*{} FROM FLIGHTS WHERE flight_no = '{}'
".format (passenger, num)
my_cursor.execute(query13)
print(f"\nnames = {nam} age = {ag} gender = {gen}")
print(f"flight name = {an} departure = {de} destination = {ds}")
print(f"flight number = {num} diparture time = {td} arrival time =
{ta} ")
print("class = business class")
for o in my_cursor:
[Link](o)
print(f"\nYOU HAVE TO PAY {o} RUPEES")

elif ans==1 and cl==3:


fl_no()
query14 = "SELECT (CHARGES +CHARGES*0.4)*{} FROM FLIGHTS WHERE FLIGHT_NO =
'{}'".format (passenger, num)
my_cursor.execute(query14)
print(f"\nnames = {nam} age = {ag} gender = {gen}")
print(f"flight name = {an} departure = {de} destination = {de}")
print(f"flight number = {num} diparture time = {td} arrival time =
{ta} ")
print("class = first class")
for p in my_cursor:
[Link](p)
print(f"\nYOU HAVE TO PAY {p} RUPEES")
elif ans==2 and cl==1:
fl_nm()
query15 = "SELECT CHARGES*{} FROM FLIGHTS WHERE airlines_name = '{}' and
DEPARTURE = '{}' and DESTINATION = '{}' ".format (passenger, fli[0], deplo[0],
arrlo[0])
my_cursor.execute(query15)
print(f"\nnames = {nam} age = {ag} gender = {gen}")
print(f"flight name = {fli} departure = {deplo} destination =
{arrlo}")
print(f"flight number = {flo} diparture time = {tdep} arrival time
= {tarr} ")
print("class = economy class")
for q in my_cursor:
[Link](q)
print(f"\nYOU HAVE TO PAY {q} RUPEES")

elif ans==2 and cl==2:


fl_nm()
query16 = "SELECT (CHARGES +CHARGES*0.2)*{} FROM FLIGHTS WHERE airlines_name =
'{}' and DEPARTURE = '{}' and DESTINATION = '{}' ".format (passenger, fli[0],
deplo[0], arrlo[0])
my_cursor.execute(query16)
print(f"\nnames = {nam} age = {ag} gender = {gen}")
print(f"flight name = {fli} departure = {deplo} destinatio =
{arrlo}")
print(f"flight number = {flo} diparture time = {tdep} arrival time
= {tarr} ")
print("class = business class")
for r in my_cursor:
[Link](r)
print(f"\nYOU HAVE TO PAY {r} RUPEES")

elif ans==2 and cl==3:


fl_nm()
query17 = "SELECT (CHARGES +CHARGES*0.4)*{} FROM FLIGHTS WHERE airlines_name =
'{}' and DEPARTURE = '{}' and DESTINATION = '{}' ".format (passenger, fli[0],
deplo[0], arrlo[0])
my_cursor.execute(query17)
print(f"\nnames = {nam} age = {ag} gender = {gen}")
print(f"flight name = {fli} departure = {deplo} destination =
{arrlo}")
print(f"flight number = {flo} diparture time = {tdep} arrival time
= {tarr} ")
print("class = first class")
for s in my_cursor:
[Link](s)
print(f"\nYOU HAVE TO PAY {s} RUPEES")

pay = input("\nTO PAY PRESS (P):-")

if pay=='p' or pay=='P':
print("\nHOW YOU WANT TO PAY ?")
print("[Link] PAY")
print("[Link] PAY")
print("[Link]")
print("[Link] PAY")
print("[Link] CARD")
print("[Link] CARD")
print("[Link] TRANSFER")

pay2 = int(input("\nENTER YOUR PAYMENT METHOD (1/2/3/4........):-"))

if pay2==1:
print("\n-------------------GOOGLE PAY---------------------------")
print(F"PAY {payment[0]} RUPEES")
pay3 = input("\nTO CONTINUE PAYMENT PRESS (P):-")
ott = int(input("\nENTER A OTP SENT TO YOUR PHONE NO AND EMAIL:-"))
print("\nTRANSACTION SUCCESSFUL------------")
print("\n**********THANK YOU***********")

if pay2==2:
print("\n-------------------AMAZON PAY---------------------------")
print(F"PAY {payment[0]} RUPEES")
pay3 = input("\nTO CONTINUE PAYMENT PRESS (P):-")
ott = int(input("\nENTER A OTP SENT TO YOUR PHONE NO AND EMAIL:-"))
print("\nTRANSACTION SUCCESSFUL------------")
print("\n**********THANK YOU***********")

if pay2==3:
print("\n-------------------PAYPAL---------------------------")
print(F"PAY {payment[0]} RUPEES")
pay3 = input("\nTO CONTINUE PAYMENT PRESS (P):-")
ott = int(input("\nENTER A OTP SENT TO YOUR PHONE NO AND EMAIL:-"))
print("\nTRANSACTION SUCCESSFUL------------")
print("**********THANK YOU***********")

if pay2==4:
print("\n-------------------APPLE PAY---------------------------")
print(F"PAY {payment[0]} RUPEES")
pay3 = input("\nTO CONTINUE PAYMENT PRESS (P):-")
ott = int(input("\nENTER A OTP SENT TO YOUR PHONE NO AND EMAIL:-"))
print("\nTRANSACTION SUCCESSFUL------------")
print("**********THANK YOU***********")

if pay2==5 or pay2==6:
print("\n-------------------CARD payment---------------------------")
print(F"PAY {payment[0]} RUPEES")
c_no = int(input("\nENTER YOUR CARD NO:-"))
cvv = int(input("\nENTER YOUR CVV:-"))
ott2 = int(input("\nENTER A OTP SEND TO YOUR NUMBER:-"))
print("\nTRANSACTION SUCCESSFUL------------")
print("**********THANK YOU***********")

print("\n--------THANKS FOR USING FLIGHT BOOKING SYSTEM--------------")


print(f"\nYOUR TICKETS ARE SEND TO YOUR EMAIL {e[0]} ")
print("\nSEE YOU LATER :)")

[Link]()

Common questions

Powered by AI

The flight booking system might use several data tables within its underlying database, including 'Users' to store account information such as email, password, and contact details; 'Flights' to maintain flight details like flight number, airlines name, departure and arrival locations, and timings; 'Bookings' to keep records of individual reservations or queries including passenger information, selected flights, and chosen classes; 'Payments' to record transaction details and payment method choices. Justification for these selections stems from the system's need to effectively manage user accounts, flight data, booking operations, and payment processing as outlined in the steps described in the document sources .

User feedback loops are significant in the flight booking system as they provide valuable insights into user satisfaction, system effectiveness, and areas for improvement. These loops can be implemented by integrating post-transaction surveys to collect immediate feedback on user experience, prompting users to rate elements such as ease of use, payment processing, and satisfaction with flight options. Implementing feedback mechanisms directly in the user interface can ensure that the system evolves in response to actual user needs and preferences. Additionally, feedback can be aggregated to generate analytical reports to inform system upgrades or feature developments, ultimately enhancing overall user satisfaction and system reliability .

The OTP (One-Time Password) is a critical security feature used at multiple points in the flight booking system to verify user identity and secure transactions. It ensures that the account login process is secure by requiring users to confirm their identity via a code sent to their registered email and phone number. Furthermore, the OTP is used during the payment process to authenticate the user's payment method and confirm the transaction. This added layer of verification helps prevent unauthorized access and secures financial transactions by ensuring that only the legitimate account holder can complete these actions. Through consistent use of OTPs, the system bolsters its security, protecting users from potential fraud .

Security failures in the flight booking system can have severe impacts, including unauthorized access to user accounts, financial fraud, and the exposure of sensitive personal data. These failures undermine user trust, likely leading to reputation damage and user attrition. To mitigate such risks, preventative measures are crucial. These include implementing robust encryption protocols for data transmission, enforcing multi-factor authentication across critical user interactions, and conducting regular security audits to identify and address vulnerabilities. Additionally, user education on recognizing phishing attempts and strengthening passwords can enhance overall security, preserving system integrity and user trust .

The system promotes data entry accuracy by structuring the input process in a step-by-step manner where users are prompted to enter critical information such as passenger details and flight data explicitly. This structured input method reduces the likelihood of errors by isolating fields like name, age, and gender for passengers, ensuring that each piece of information is gathered separately. It further validates flight data accuracy by requiring flight numbers or verifying departures and arrivals against pre-stored database values. The distinct separation and verification of data points help in minimizing user mistakes, thus maintaining high accuracy in captured data .

The system is designed to accommodate booking modifications and user continuity in the flight selection process by offering flexibility after viewing flight details. Users are prompted to decide whether they want to continue with the current selection or make changes by re-entering the flight data query. It provides an option for users to adjust their chosen flights by either confirming the present choice or reverting to explore more options without restarting the entire booking process. This design allows users to carefully review their choices and ensures they can adapt their bookings to best meet their needs, enhancing user satisfaction by maintaining continuity .

In the flight booking system, CSV files are employed to temporarily store user data, specifically passenger details such as name, age, and gender. This use case arises when gathering data for individual bookings, allowing for organized entry before confirmation and processing. The CSV files serve as a mechanism to ensure that collected data is well-structured before it undergoes further integration into the booking system, potentially aiding in debugging or as an intermediary step when transferring data to a database or during user verification stages .

If you already have an account in the flight booking system, the steps are as follows: You need to log in using your email and password. After logging in, you are prompted to enter an OTP sent to your email and phone number. Upon successful login, you will choose how to search for a flight, either by flight number or manually by specifying departure and arrival locations. If you choose by flight number, you enter the flight number to retrieve flight data. If you choose to search manually, you specify the departure and arrival locations to find available flights, then select a flight and view its details. After selecting a flight, you can decide whether to continue or make any changes. Next, enter passenger information, choose the class, and finally make the payment through one of the available methods. A successful booking will be confirmed by sending the tickets to your email .

Using CSV files to store user data can introduce challenges such as data integrity issues, limited scalability, and concurrency problems. CSV files are flat files without constraints, meaning they can easily become corrupted or inconsistent if accessed simultaneously. Additionally, they lack the transactional integrity and relational schema enforcement inherent in database systems, which are crucial for maintaining accurate user records in case of multiple updates or queries. Potential solutions include migrating user data storage to a robust relational database system like MySQL, where data integrity can be preserved through schema constraints, ACID compliance can ensure safe concurrent processes, and scalability can handle the growing data volume as system usage increases .

The flight booking system processes payments by allowing users to select a preferred method from various options. After finalizing flight selection, the user is prompted to select a payment method from the following options: Google Pay, Amazon Pay, PayPal, Apple Pay, Credit Card, Debit Card, or Bank Transfer. For each selected method, the system requests confirmation to proceed with an OTP-based verification, ensuring transaction security. When the payment is confirmed (user presses 'P'), the system verifies the OTP sent to the user's phone and email, and upon validation, the transaction is completed. Successful payments are followed by a confirmation message, and the system sends tickets to the user's registered email .

You might also like