Computer Project Online Bus Report Class 12
Computer Project Online Bus Report Class 12
PROJECT
BONAFIDE CERTIFICATE
Certified to be the Bonafide work done by Mr
. Aaron Jacob Anish of class XII-B during the Academic Year
2024-2025.
Dated:
Mrs. Merine Ann
UNITED INDIAN SCHOOL
Abbasiya - Kuwait
Dated:
External Examiner
DECLARATION
“ We hereby declare that this Project titled ONLINE
BUS RESERVATION SYSTEM is an authentic work
prepared by us during the academic year 2024-2025
under the guidance of Mrs. Merine Ann.”
ACKNOWLEDGEMENT
First and foremost, praises and thanks to the God,
the Almighty, for his showers of blessings
throughout my research work to complete
the research and project successfully. Very
sincere thanks to my computer science
teacher,
MRS. MERINE ANN , who has been an
immense support to me. I am extremely grateful to
my parents for their love, prayers and support for
this project.
CONTENTS
SLNO CONTENTS PAGE NO
1 Abstracts 5
i. Features of python 5
3 Need of computerization 9
5 Documentation 11
6 Source code 13
7 Output screens 19
8 Bibliography 24
ABSTRACT
FEATURES OF PYTHON
Python is an open source, object oriented, high-level
programming language, which was developed by Guido
van Rossum in 1991.
FEATURES
Easy to Use (User Friendly): Python is a compact and very easy
to use object oriented language with very simple syntax
rules. It is a high level programming language that has English
like syntax. This makes it easier to read and understand the
code.
Interpreted Language: Python is an interpreted language.
Python interpreter interprets and executes the code, line
by line at a time. So it’s an easy to debug language and thus
suitable for beginners to advanced users.
Cross-platform language: Python can run across different
platform like Windows, Linux, Mac OS and other OS.
Open source and free software: Python is freely available, open
source, portable language. And not only it is free, it’s
source code is also available.
5
Features of MySQL
MySQL is a free open source RDBMS software that uses
structured query language.
It is a fast and reliable RDBMS. It was invented by Michael
Widenius and the logo of MySQL is a dolphin named “Sakila”.
Features
Speed: MySQL runs very fast.
Free of cost: MySQL is available free of cost, i.e, MySQL is an
open source of software i.e, one can freely download the
software from the internet.
EASE OF USE: It is a high-performance, relatively simple
database system and can be managed from the command
line.
Portability: It can be used easily on multiple CPUs and is
available on multiple platforms.
Security: It offers priviledge and password system that is very
flexible and secure and allows the verification by the host
computer.
Datatypes: It provides many datatypes to support different
types of data.
6
PYTHON-MySQL CONNECTIVITY
The term “front-end” refers to the user interface, while
“back-end” means the server, application and database that
work behind the scenes to deliver information to the user.
The user enters a request through the interface.
Examples of front-end databases: PHP, Java, Python
Examples of back-end databases: MySQL, SQL server,
PostgresSQL, Oracle.
Start Python
Import the packages required for database programming
Open a connection
Create a cursor instance
Execute a query
Extract data from result set
Clean up the environment
7
HARDWARE AND
SOFTWARE SPECIFICATION
HARDWARE REQUIREMENTS
SOFTWARE REQUIREMENTS
8
NEED FOR COMPUTERISATION
Computers have made great inroads in our everyday lives
and thinking. Computers can access and process data
hundred times faster than human beings do. They are
used for all sorts of applications ranging from complex
communication in the field of research, engineering
stimulation, down to teaching, printing books and
recreational games. The ease with computer processes
data and retrieve it painlessly has made it inevitable in the
office and business environment.
9
AIM OF THE PROJECT
This project on Online Bus Reservation System aims at
creating a program which helps to add, delete, modify,
searching, displaying a record from a database relation
stored in MYSQL.
10
TABLE STRUCTURE
12
BUS RESERVATION
SOURCE CODE:
import mysql.connector as sql
mycon=sql.connect(host="localhost",user="root",password="passwo
rd",database="ONLINE")
if mycon.is_connector()==False:
print("Error connecting to Mysql database")
cursor=mycon.cursor()
def SelectAll():
cursor.execute("Select * from BUSRESERVATION")
data=cursor.fetchall()
count=cursor.rowcount
print("Total number of records:",count)
for row in data:
print(row)
def insertrecord():
cursor.reset()
while True:
bn=int(input("Enter the Bus No"))
13
ba=input("Enter the Bus Name")
pa=input("Enter the Passenger Name")
dt=input("Enter the Departure Time")
ar=input("Enter the Arrival Time")
fc=input("Enter the Source")
tc=input("Enter the Destination")
ag=int(input("Enter the Age"))
fr=float(input("Enter the Fare"))
query1=("insert into
BUSRESERVATION(Bus_No,Bus_Name,Passenger_Name,Departure_T
ime,Arrival_Time,Source,Destination,Age,Fare)""values(%s,%s,%s,%s
,%s,%s.%s,%s,%s)")
cursor.execute(query1,(bn,ba,pa,dt,ar,fc,tc,ag,fr))
mycon.commit()
ch=input("Do you want to insert another record?")
if ch.upper()=="N":
break
def modify():
cursor.reset()
while True:
bn=int(input("enter the Bus No whose record you want to
modify:"))
14
pa=input("Enter the Passenger Name")
ba=input("Enter the Bus Name")
query1="update BUSRESERVATION set Passenger_Name=
%s,Bus_Name=%s,where Bus_No=%s"
cursor.execute(query1,(pa,ba,bn))
mycon.commit()
ch=input("Do you want to modify another record?")
if ch.upper()=="N":
break
def deleterec():
cursor.reset()
while True:
bn=int(input("enter the Bus No whose record you want
to delete:"))
cursor.execute("Delete from BUSRESERVATION where Bus_No=
%s",(bn,))
mycon.commit()
ch=input("Do you want to delete another record?")
if ch.upper()=="N":
break
def search(bn):
cursor.reset()
15
cursor.execute("Select * from BUSRESERVATION where Bus_No=%s",
(bn,))
data=cursor.fetchall()
count=len(data)
print("Total number of rows retrieved from result
set:",count) for row in data:
print(row)
def searchName():
cursor.reset()
pa=input("Enter the passenger name of whose record you want to
search:")
bn=int(input("Enter the Bus No whose record you want to
search:"))
cursor.execute("Select * from BUSRESERVATION where
Bus_No=%s and Passenger_Name=%s",(bn,pa))
data=cursor.fetchall()
count=len(data)
print("Total number of rows retrieved from result
set:",count) for row in data:
print(row)
print("WELCOME TO ONLINE BUS RESERVATION")
def displayage(n):
16
cursor.execute("Select * from BUSRESERVATION where age=
%s"(n,))
data=cursor.fetchall()
count=len(data)
print("Total number of rows retrieved from result
set:",count) for row in data:
print(row)
def cleanup():
mycon.close()
ch=0
while ch!=8:
print("1.DISPLAY ALL RECORDS")
print("2.BOOK A TICKET")
print("3.UPDATE THE CLASS OF THE TICKET")
print("4.CANCEL A TICKET")
print("5.SEARCH FOR A TICKET DETAIL BASED ON BUS NO")
print("6.SEARCH FOR THE DETAIL OF A PARTICULAR PASSENGER")
print("7.DISPLAY THE PASSENGER BASED ON THEIR AGE")
print("8.QUIT")
ch=int(input("ENTER YOUR CHOICE"))
if ch==1:
17
SelectAll()
elif ch==2:
insertrecord()
elif ch==3:
modify()
SelectAll()
elif ch==4:
deleterec()
SelectAll()
elif ch==5:
bn=int(input("Enter the Bus No"))
search(bn)
elif ch==6:
n=int(input("Enter the age of the passenger to be displayed:"))
displayage(n)
else:
break
cleanup()
18
OUTPUTS
Displaying all records
19
Inserting new record
20
Deleting a record
21
Searching record based on Bus No
22
Displaying records based on their Age
23
BIBLIOGRAPHY
Computer Science with PYTHON-Priti Arora
Computer Science with PYTHON-Sumita Arora
24