0% found this document useful (0 votes)
24 views

Cs Project

The document contains source code and instructions for an airline reservation system project built with Python and MySQL, including functions for booking flights by entering passenger details and confirming the booking by inserting records into booking and flights tables in the MySQL database. It also includes SQL commands for creating the database tables and inserting initial flight records.

Uploaded by

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

Cs Project

The document contains source code and instructions for an airline reservation system project built with Python and MySQL, including functions for booking flights by entering passenger details and confirming the booking by inserting records into booking and flights tables in the MySQL database. It also includes SQL commands for creating the database tables and inserting initial flight records.

Uploaded by

Deepika V
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

INDEX

Index 1

Introduction To Python 2

Features Of Python 2

Requirements 6

Mysql Overview 7

Project Criteria 8

Source Code 9

Output 20

Conclusion 23
INTRODUCTION TO PYTHON

Python is a popular programming language. It was created by Guido


van Rossum, and released in 1991.

It is used for:

● Web development (server-side),


● Software development,
● Mathematics,
● System scripting.

Python was designed for readability, and has some similarities to the
English language with influence from mathematics. Python uses new
lines to complete a command, as opposed to other programming
languages which often use semicolons or parentheses. Python relies
on indentation, using whitespace, to define scope; such as the scope
of loops, functions and classes. Other programming languages often
use curly-brackets for this purpose.

2
FEATURES OF PYTHON

There are many features in Python, some of which are discussed


below as follows:

1. Free and Open Source


Python language is freely available at the official website. Since it is
open-source, this means that source code is also available to the
public. So you can download it, use it as well as share it.

2. Easy to code
Python is a high-level programming language. Python is very easy to
learn the language as compared to other languages like C, C#,
Javascript, Java, etc. It is very easy to code in the Python language
and anybody can learn Python basics in a few hours or days. It is also
a developer-friendly language

3. Easy to Read
Learning Python is quite simple. Python’s syntax is really
straightforward. The code block is defined by the indentations rather
than by semicolons or brackets.

4. Object-Oriented Language

3
One of the key features of Python is Object-Oriented programming.
Python supports object-oriented language and concepts of classes,
object encapsulation, etc.

5. GUI Programming Support


Graphical User interfaces can be made using a module such as
PyQt5, PyQt4, wxPython, or Tk in python. PyQt5 is the most popular
option for creating graphical apps with Python.

6. High-Level Language
Python is a high-level language. When we write programs in Python,
we do not need to remember the system architecture, nor do we
need to manage the memory.

7. Extensible feature
Python is an Extensible language. We can write some Python code
into C or C++ language and also we can compile that code in C/C++
language.

8. Easy to Debug
Excellent information for mistake tracing. You will be able to quickly
identify and correct the majority of your program’s issues once you
understand how to interpret Python’s error traces. Simply by

4
glancing at the code, you can determine what it is designed to
perform.

9. Python is a Portable language


Python language is also a portable language. For example, if we have
Python code for windows and if we want to run this code on other
platforms such as Linux, Unix, and Mac then we do not need to
change it, we can run this code on any platform.

10. Python is an Integrated language


Python is also an Integrated language because we can easily
integrate Python with other languages like C, C++, etc.

11. Interpreted Language


Python is an Interpreted Language because Python code is executed
line by line at a time. Unlike other languages C, C++, Java, etc.
there is no need to compile Python code. This makes it easier to
debug our code. The source code of Python is converted into an
immediate form called bytecode.

12. Large Standard Library


Python has a large standard library that provides a rich set of
modules and functions so you do not have to write your own code for

5
every single thing. There are many libraries present in Python such
as regular expressions, unit-testing, web browsers, etc.

13. Dynamically Typed Language


Python is a dynamically-typed language. That means the type (for
example- int, double, long, etc.) for a variable is decided at run
time not in advance because of this feature we don’t need to specify
the type of variable.

14. Frontend and backend development


With a new project py script, you can run and write Python codes in
HTML with the help of some simple tags <py-script>, <py-env>, etc.
This will help you do frontend development work in Python like
javascript. Backend is the strong forte of Python; it's extensively
used for this work because of its frameworks like Django and Flask.

15. Allocating Memory Dynamically


In Python, the variable data type does not need to be specified. The
memory is automatically allocated to a variable at runtime when it is
given a value. Developers do not need to write int y = 18 if the
integer value 15 is set to y. You may just type y=18.

6
REQUIREMENTS
Operating system Windows 7 or above

Processor Intel(R) Core TMi7

RAM 512MB+

HARD DISK SATA 40GB or Above

CD/DVD (If back up required)

Printer Required to take hard copy

Programming Language IDLE(Python3.8,32bit)


MySQL

MySQL OVERVIEW

MySQL was created by a Swedish company, MySQL AB, founded by


Swedes David Axmark, Allan Larsson and Finland Swede Michael
"Monty" Widenius.
Original development of
MySQL by Widenius and
Axmark began in
1994.The first version of
MySQL appeared on 23
May 1995. It was initially

7
created for personal usage from mSQL based on the low-level
language ISAM, which the creators considered too slow and
inflexible. They created a new SQL interface, while keeping the
same API as mSQL. MySQL Server 5.5 was generally available (as of
December 2010). Enhancements and features include:

● The default storage engine is InnoDB, which supports


transactions and referential integrity constraints.
● Improved InnoDB I/O subsystem
● Improved SMP support
● Semisynchronous replication.

MySQL is a database management system.It may be anything from a


simple shopping list to a picture gallery or the vast amounts of
information in a corporate network. To add, access, and process data
stored in a computer database, you need a database management
system such as MySQL Server.The SQL part of “MySQL” stands for
“Structured Query Language”. SQL is the most common standardized
language used to access databases. MySQL is the most secure
database management system in the world.

Advantages Of MySQL

1. Open Source
2. Data Security
3. Scalability On Demand

8
4. Higher Efficiency
5. 24×7 Server Uptime

PROJECT CRITERIA

The objective of the project is to design an Airline Reservation


System application which enables the customers to search and book
flights. The project has been designed in python technology and
consists of an MySQL server which acts as the database for the
project. The Airline Reservation System project mainly consists of
two types of users. The customers who access the information
provided by the website and the administrator who modifies and
updates the information available on the website.

SOURCE CODE

INSTRUCTIONS FOR MySQL

#MYSQL COMMANDS FOR PROJECT-

CREATE DATABASE airsys;

USE airsys;

CREATE TABLE FLIGHTS(FNO varchar(5) primary key,AIRLINES varchar(15), SOURCE varchar(15),


DESTINATION varchar(15),FARE int(7), FLIGHT_DATE date,FLIGHT_TIME time);

INSERT INTO FLIGHTS VALUES("AI045","AIR ITALY","BRASILIA","FLORENCE",45000,"2019-06-07",10000);

INSERT INTO FLIGHTS VALUES("EM390","EMIRATES","BRISBANE","DUBAI",65000,"2019-08-07",90000);

INSERT INTO FLIGHTS VALUES("IN990","INDIGO","GOA","MAURITIUS",34000,"2019-09-29",180000);

9
INSERT INTO FLIGHTS VALUES("LF007","LUFTHANSA","TOKYO","WISCONSIN",70000,"2019-06-07",80000);

INSERT INTO FLIGHTS VALUES("QR555","QATAR","LAS VEGAS","PARIS",89000,"2020-02-14",210000);

CREATE TABLE BOOKINGS (BNO varchar (5) primary key , FNO varchar(5) not null ,PASSENGER_NAME
varchar(25),GENDER char(1), AGE int(2));

ALTER TABLE BOOKINGS ADD CONSTRAINT FOREIGN KEY(FNO) REFERENCES FLIGHTS(FNO);

INSERT INTO BOOKINGS VALUES(1000,"AI045","LISA CRUISE","F",24);

PYTHON PROGRAM
#FEW FUNCTIONS FOR CODE-

def bo():

while True:

import mysql.connector
r=input("Enter FNO (Flight Number): ")

db=mysql.connector.connect(host='localhost',user='root',password='ann
ie@MySQL2023',database='airsys')
cursor=db.cursor()
Query1=("select * from flights where FNO='%s'" %(r))
cursor.execute(Query1)
res=cursor.fetchall()

if not res:
print("No such flight exists")
cursor.close()

else:
print("Enter passenger details: ")
s=input("Enter your name: ")

while True:
t=int(input("Enter your age: "))

10
if t>100 or t<=0:
print("Enter age 0 to 100")
else:
break

while True:
u=input("Enter your gender(F/M): ")
if not (u=="F" or u=="M"):
print("Enter only F or M")
else:
break

print("This is your booking-","FNO:",r,",


PASSENGER_NAME:",s,", AGE:",t,", GENDER:",u,end='\n')
o=input("Are you sure you want to confirm this booking?
(Y/N): ")

if o!="Y":
break

else:

cursor.execute("Select max(bno)from bookings")


result=cursor.fetchall()

for i in result:
tbno=int(i[0])

l=tbno+1
Query=("insert into
bookings(BNO,FNO,PASSENGER_NAME,AGE,GENDER) values(%s,%s,%s,%s,%s)")
data=(l,r,s,t,u)
cursor.execute(Query,data)
db.commit()
print("Your booking has been confirmed.\n")
print("This is your booking-","YOUR BOOKING NO:",l,",
FNO:",r,", PASSENGER_NAME:",s,", AGE:",t,", GENDER:",u,end='\n')
cursor.close()

11
break

def db():

import mysql.connector

r=input("Enter booking number: ")

db=mysql.connector.connect(host='localhost',user='root',password='ann
ie@MySQL2023',database='airsys')
cursor=db.cursor()
Query1=("select * from bookings where BNO='%s'" %(r))
cursor.execute(Query1)
res=cursor.fetchall()

if not res:

print("No such booking exists")

else:
f=input("Are you sure you want to delete this booking (Y/N):
")

if f=='Y':
Query=("delete from bookings where BNO='%s'" %(r))
cursor.execute(Query)
db.commit()

print("Booking number '%s' has been successfully


deleted."%(r))

cursor.close()

def af():

12
import mysql.connector

db=mysql.connector.connect(host='localhost',user='root',password='ann
ie@MySQL2023',
database='airsys')
cursor=db.cursor()
cursor.execute("select * from flights")
result=cursor.fetchall()

print("{0:10}{1:12}{2:14}{3:15}{4:7}{5:13}{6:12}".format("===","=====
===","======","===========","====","===========","==========="))

print("{0:10}{1:12}{2:14}{3:15}{4:7}{5:13}{6:12}".format("FNO","AIRLI
NES","SOURCE","DESTINATION","FARE","FLIGHT_DATE","FLIGHT_TIME"))

print("{0:10}{1:12}{2:14}{3:15}{4:7}{5:13}{6:12}".format("===","=====
===","======","===========","====","===========","==========="))

for x in result:

print
("{0:10}{1:12}{2:14}{3:13}{4:6}".format(x[0],x[1],x[2],x[3],x[4]),"
",x[5]," ",x[6])

cursor.close()

def anf():

import mysql.connector

h=input("Enter flight number: ")

db=mysql.connector.connect(host='localhost',user='root',password='ann
ie@MySQL2023',
database='airsys')
cursor=db.cursor()

13
Query1=("select * from flights where FNO='%s'" %(h))
cursor.execute(Query1)
res=cursor.fetchall()

if not res:

a=input("Enter name of airlines: ")


b=input("Enter source: ")
c=input("Enter destination: ")
e=int(input("Enter flight fare: "))
f=input("Enter flight date (YYYY-MM-DD): ")
g=input("Enter flight time (HH:MM:SS): ")
Query=("insert into
flights(FNO,AIRLINES,SOURCE,DESTINATION,FARE,FLIGHT_DATE,FLIGHT_TIME)
values(%s,%s,%s,%s,%s,%s,%s)")
data=(h,a,b,c,e,f,g)
cursor.execute(Query,data)
db.commit()

print("New Flight number '%s' has been successfully added."


%(h))

cursor.close()

else:

print("No such flight exists")


cursor.close()

def ef():

import mysql.connector
r=input("Enter flight number: ")

db=mysql.connector.connect(host='localhost',user='root',password='ann
ie@MySQL2023',database='airsys')
cursor=db.cursor()

14
Query1=("select * from flights where FNO='%s'" %(r))
cursor.execute(Query1)
res=cursor.fetchall()

if not res:

print("No such flight exists")

cursor.close()

else:

print("MENU OF
FIELDS","\n","1.AIRLINES","\n","2.SOURCE","\n","3.DESTINATION","\n","
4.FARE","\n","5.FLIGHT_DATE","\n","6.FLIGHT_TIME")
m=int(input("Enter your choice of field which you wish to
update: "))

o={1:'AIRLINES',2:'SOURCE',3:'DESTINATION',4:'FARE',5:'FLIGHT_DATE',6
:'FLIGHT_TIME'}
q=o.get(m)
n=input("Enter new value: ")

Query=("update flights set %s='%s' where FNO='%s'"%(q,n,r))


cursor.execute(Query)
db.commit()

print("\nFor flight number '%s', '%s' has been successfully


updated to '%s'."%(r,q,n))

cursor.close()

def df():

import mysql.connector

r=input("Enter flight number: ")

15
db=mysql.connector.connect(host='localhost',user='root',password='ann
ie@MySQL2023',database='airsys')
cursor=db.cursor()
Query1=("select * from flights where FNO='%s'" %(r))
cursor.execute(Query1)
res=cursor.fetchall()

if not res:

print("No such flight exists")

else:
query2=("select count(*) from bookings where FNO='%s'" %(r))
cursor.execute(query2)
rs=cursor.fetchall()

if (rs[0][0])>0:

print("This flight can not be deleted because a booking


already exists.")

else:
f=input("Are you sure you want to delete this flight
(Y/N): ")

if f=='Y':
Query=("delete from flights where FNO='%s'" %(r))
cursor.execute(Query)
db.commit()

print("Flight number '%s' has been successfully


deleted."%(r))

cursor.close()

16
def vb():

import mysql.connector

db=mysql.connector.connect(host='localhost',user='root',password='ann
ie@MySQL2023',
database='airsys')
cursor=db.cursor()
cursor.execute(" select
BOOKINGS.FNO,BNO,PASSENGER_NAME,GENDER,AGE,AIRLINES,SOURCE,DESTINATIO
N,FARE,FLIGHT_DATE,FLIGHT_TIME from FLIGHTS,BOOKINGs where
FLIGHTS.FNO=BOOKINGS.FNO")
reesult=cursor.fetchall()

print("{0:10}{1:10}{2:15}{3:8}{4:5}{5:12}{6:14}{7:15} {8:8}
{9:13}{10:13}".format("===","===","==============","=====","===","===
======","=====","============"," ====","===========","==========="))
print("{0:10}{1:10}{2:15}{3:8}{4:5}{5:12}{6:14}{7:15} {8:8}
{9:13}{10:13}".format("FNO","BNO","PASSENGER_NAME","GENDER","AGE","AI
RLINES","SOURCE","DESTINATION"," FARE","FLIGHT_DATE","FLIGHT_TIME"))
print("{0:10}{1:10}{2:15}{3:8}{4:5}{5:12}{6:14}{7:15} {8:8}
{9:13}{10:13}".format("===","===","==============","=====","===","===
======","=====","============"," ====","===========","==========="))

for xx in reesult:
age=xx[4]
fare=xx[8]

print("{0:10}{1:10}{2:15}{3:6}{4:5}
{5:12}{6:14}{7:15}{8:8}".format(xx[0],xx[1],xx[2],xx[3],age,xx[5],xx[
6],xx[7],fare)," ",xx[9]," ",xx[10])

cursor.close()

#MAIN CODE-

17
import getpass

while True:

print("****************************** \nWELCOME TO OUR AIRLINE


SYSTEM \n******************************","\n")

a=input("Are you a Customer or an Admin?(C/A): ")

if a=="C":

print("\n Welcome Customer!","\n")

while True:

try:

print("--------------------------------\nCustomer
Menu:\n-------------------------------- \n 1. Available
flights","\n","2. Book a flight","\n","3. Cancel Booking","\n","4.
Exit from Customer Menu","\n","5. Exit from Airline System","\n")

b=int(input("Enter your choice: (1/2/3/4/5)\n"))

if b==1:
af()
elif b==2:
bo()
elif b==3:
db()
elif b==4:
break
elif b==5:
print("Goodbye")
quit()
else:
print("Enter a number between 1 to 4 only")

18
except(ValueError,TypeError,NameError):
print("Enter correct values")

elif a=="A":

while True:
pwrd=input("Enter password: ")

if pwrd=="admin09":
print("\n","Welcome Administrator!","\n")

while True:

try:

print("-----------------------------------\nAdmin Menu:
\n----------------------------------- \n 1. Available
flights","\n","2. Add a new flight","\n","3. Edit a flight","\n","4.
Delete a flight","\n","5. View all bookings","\n","6. Exit from Admin
Menu","\n","7. Exit from Airline System","\n")
c=int(input("Enter your choice:
(1/2/3/4/5/6/7) \n"))

if c==1:
af()
elif c==2:
anf()
elif c==3:
ef()
elif c==4:
df()
elif c==5:
vb()
elif c==6:
break
elif c==7:

19
print("Goodbye")
quit()
else:
print("Enter a number between 1 to 7
only")

except(ValueError,TypeError,NameError):
print("enter correct values")
break

else:
print("Incorrect password.","\n")

else:
print("Enter only A or C")

OUTPUT

20
21
22
CONCLUSION

The Airline reservation system has been a way of clerical work,


which is almost a routine and consumes the most precious time. This
Airline Reservation System has been an attempt to help the user to
minimize his workload along with minimizing the paperwork and
saving time. The system has been developed in a way to make it very
user friendly. It provides online messages every time the user needs
it. Any person having a little bit of window based can run this system
without any pain.

23

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy