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

Computer_project[1] (AutoRecovered)

The document is a project report for an Online Railway Reservation System developed as part of the Computer Science course for AISSCE 2024-25. It outlines the project's objectives, methodology, and working description, detailing user functionalities for both customers and railway employees, as well as the technical implementation using Python and MySQL. The report includes acknowledgments, certification, and a structured table of contents, along with code snippets for the database and application logic.

Uploaded by

ribhav2000
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Computer_project[1] (AutoRecovered)

The document is a project report for an Online Railway Reservation System developed as part of the Computer Science course for AISSCE 2024-25. It outlines the project's objectives, methodology, and working description, detailing user functionalities for both customers and railway employees, as well as the technical implementation using Python and MySQL. The report includes acknowledgments, certification, and a structured table of contents, along with code snippets for the database and application logic.

Uploaded by

ribhav2000
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 48

CHEMI

For AISSCE 2024-25 Examination


As a part of the Computer Science
Course (083)
SUBMITTED BY-
[Name]
Class XII Sc1
AISSCE Roll no-
CERTIFICATE

This is to certify that __________________ of


class XII SC (I) have prepared the report on
1|Page
the project entitled “Online Railway
Reservation system”. The report is the result
of their efforts and endeavours. The report
is found worthy of acceptance as final
project report for the subject of Computer
Science of Class XII. They have prepared the
report under my guidance.

(Mrs. Yamini Azhaguvel)


PGT(Computer
Science)

2|Page
ACKNOWLEDGMENT
I would like to express a deep sense of thanks
and gratitude to my project guide Mrs. Yamini
Azhaguvel, for guiding me immensely through
the course of the project. She always evinced a
keen interest in my work. Her constructive advice
and constant motivation have been responsible
for the successful completion of this project.

My sincere thanks go to Mrs. Suchitra


Banhyopadhyay, our principal, for her co-
ordination in extending every possible support
for the completion of this project.

I also thank my parents for their motivation and


support. I must also thank my classmates for
their timely help and support for the completion
of this project.

Lastly, I would like to thank all those who had


helped directly or indirectly towards the
completion of this project.

Class: XII Sc 1

3|Page
CONTENTS

 Certification

 Acknowledgment

 Objective and scope of the project

 Theoretical Background

 System of planning and Methodology

 Working Description

 Written Code

 Input and Output screens

 Structure of tables in MySQL

 Bibliography

4|Page
OBJECTIVE AND SCOPE OF THE
PROJECT
The Online Railway Reservation System is a user-
friendly platform designed to simplify the process
of booking train tickets and managing
reservations. The system allows users to log in as
employee or customer and create or delete
customer account. First time user must create an
account and then sign in. Once signed in the
system allows users to book tickets by selecting
their boarding and destination stations and view
available trains. Once a train is selected, users
can specify the passenger details and book
tickets. Additionally, users can check their
current bookings, PNR status and cancel tickets if
necessary. The system also provides train
schedules to help users plan their journeys more
effectively.
For railway employees, the system offers
functionalities to manage train details, including
adding or removing trains and viewing customer
details for administrative purposes.
The backend of the system is powered by MySQL,
which stores user information, train details,
stations and booking records while Python
handles the frontend interactions. Overall, the
system aims to make railway reservation more
accessible, reducing the dependency on physical

5|Page
counters, and offering a convenient experience
for both passengers and railway staff.

THEORETICAL BACKGROUND

This project was completed using the methods


which can be used in connecting MySQL and
Python together.
The Front-End software is python due to its
simple structure and high capability. Python in
the project is used to calculate and operate on
the data pre-fed into the program and display the
user interface and lets the user manipulate data
as they wish to do using various simple menus
which are connected to each thus making the use
smooth and fast.
The Back End development of the software has
been done on MySQL due to its table
management system being not very complex. It
is used in the project for the storing of the
customer information, train details, stations and
booking records in form of tables which are
called by the Python project and manipulate
thereafter.
The most crucial part of the project was the use
of mysql.connector which allowed the use of the
Front End and Back End software. The methods

6|Page
like fetchone() and fetchall() along with
traversing in the tables are used in this program.

SYSTEM OF PLANNING AND


METHODOLOGY

For my Railway Reservation System project, the


planning process involved understanding both the
booking process and the technical tools required. I
began by researching how a railway reservation system
works, identifying key components such as user
registration, train search, booking, and cancellation.
Once the requirements were clear, I moved on to
designing the database in MySQL, where I created
tables for users, trains, and bookings to handle the data
efficiently.

Since Python is used for the front-end interface,


allowing users to interact with the system in a simple
way. Integrating the MySQL database with Python using
the MySQL connector was initially challenging, but after
experimenting with the methods, I gained confidence in
handling queries and data updates.

As I progressed, I focused on implementing features


step by step, testing each module thoroughly, and
resolving errors that arose. The debugging process
helped refine the system, and I learned to manage time
7|Page
effectively. Finally, I documented the project to ensure
clarity for future updates and use.

8|Page
WORKING DESCRIPTION
The program is broken into 4 major modules that
come Up on the starting screen: -
1. Log in as Employee
2. Log in as Customer
3. Create Customer Account
4. Delete Customer Account
5. Exit the application
The 5th option ends the function and allows the user
to exit the program. The other 4 methods have their
sub options to allow for user to manipulate or
display required data.
1. Log in as Employee
1. Add trains
2. Display trains
3. Select trains
4. Show Customers
5. Show Employees
6. Add Stations
7. Back
2. Log in as Customer
1. Book Ticket
2. My Bookings
3. PNR Enquiry
4. Cancel Ticket
5. Chart Vacancy
6. View Train Schedule

3. Create Customer Account


9|Page
Does not have any sub-options as this option has a
one directional functionality to create a customer
account.
4. Delete Customer Account
It also does not have any sub-options as this option
has a one directional functionality to delete a
customer account.

10 | P a g e
CODE
TABLES CODE (MySQL): -
create database railways;
use railways;
create table stations(station_name varchar(255) not
null, station_code varchar(255) not null unique
primary key);
create table Trains(train_no int not null unique
primary key, train_name varchar(255) not null
unique, from_station varchar(255) not null,
from_station_code varchar(255) not null references
stations(station_code), to_station varchar(255) not
null, to_station_code varchar(255) not null
references stations(station_code));
create table emp(emp_id varchar(255) not null
unique primary key, emp_name varchar(255) not
null, password varchar(255) not null);
create table customer(customer_id varchar(255) not
null unique primary key, customer_name
varchar(255) not null, customer_password
varchar(255) not null, ph_no varchar(255) not null
unique, gender varchar(1) not null check(gender
in('M','F')), DOB date not null, age int not null);
insert into emp values (12345, 'Mahinak Biswas',
12345);
insert into emp values (67891, 'Aryan Maiti', 67891);
insert into emp values (54321, 'Ribhav Verma',
54321);
11 | P a g e
insert into stations values ('New Delhi','NDLS');
insert into stations values ('Howrah Junction','HWH');
insert into stations values ('Chatrapati Shivaji
Maharaj Terminus','CSMT');
insert into stations values ('MGR Chennai Central
Mail','MAS');
insert into stations values ('Kanpur Central','CNB');
insert into stations values ('Prayagraj
Junction','PRYJ');
insert into stations values ('Patna Junction','PNBE');
insert into stations values ('Ahmedabad
Junction','ADI');
insert into stations values ('Vijayawada
Junction','BZA');
insert into stations values ('Varanasi Junction','BSB');
insert into stations values ('Lucknow Charbagh
NR','LKO');
insert into stations values ('Agra Fort','AF');
insert into stations values ('New Jalpaiguri
Junction','NJP');
insert into stations values ('Jaipur Juction','JP');
insert into stations values ('Amritsar Junction','ASR');
insert into stations values ('Shalimar','SHM');
insert into stations values ('Goa-Vasco Da
Gama','VSG');

12 | P a g e
insert into stations values ('Yog Nagari
Rishikesh','YNRK');
insert into stations values ('KSR Bengaluru City
Junction','SBC');
insert into stations values ('Mysuru Juction','MYS');
insert into stations values ('Kanniyakumari','CAPE');
MAIN CODE (Python): -
import mysql.connector as mysql
railways= mysql.connect(host='localhost', user='root',
password='root',database='railways')
cursor=railways.cursor()
import random
import sys
sys.setrecursionlimit(10**6)
def start():
empmer=int(input('''
Main Menu-
1. Log in as Employee (Type -> 1)
2. Log in as Customer (Type -> 2)
3. Create Customer Account (Type -> 3)
4. Delete Customer Account (Type -> 4)
5.Exit the application (Type -> 0)
Type-'''))
if empmer == 1:
empid=str(input('Enter Employee Id:'))

13 | P a g e
emppass=str(input('Enter Employee
Password:'))
cursor.execute('Use railways;')
l='''Select password from emp
where emp_id = %s;''' %(empid,)
cursor.execute(l)
data= cursor.fetchone()
if data == None:
print('Wrong Password or ID')
thank_you_3()
else :
for i in data:
if i == emppass:
print('Logged in as Employee ------')
emp()
elif empmer == 2:
cusid=str(input('Enter Customer Id:'))
cuspass=str(input('Enter Customer
Password:'))
cursor.execute('Use railways;')
l='''Select customer_password from customer
where customer_id = %s;''' %(cusid,)
cursor.execute(l)
data= cursor.fetchone()
if data == None:
print('Wrong Password or ID')

14 | P a g e
thank_you_3()
else :
for i in data:
if i == cuspass:
print('Logged in as customer ------')
customer(cusid)

elif empmer ==3:


create_customer_account()
thank_you_3()
elif empmer ==4:
delete_customer_account()
else:
print('Application closed')
def check():
r=random.randint(10000,99999)
l='''select customer_id from customer
where customer_id = %s''' %(r)
cursor.execute(l)
d=cursor.fetchone()
if d == None:
return r
else :
check()
def create_customer_account():

15 | P a g e
id = check()
name=str(input('Enter Customer Name:'))
passwd=str(input('Enter Password:'))
phno=int(input('Enter Phone Number:'))
gender=str(input("Enter Gender ('M' or 'F'):"))
DOB=str(input('Enter Date of Birth(YYYY-MM-DD
format):'))
age=int(input('Enter age:'))
cursor.execute('use railways;')
l='''insert into customer
values(%s,'%s','%s',%s,'%s','%s',%s);''' %
(id,name,passwd,phno,gender,DOB,age)
cursor.execute(l)
railways.commit()
cursor.execute(''' select * from customer
where customer_id = %s;''' %(id))
data=cursor.fetchall()
print('NOTE THE FOLLOWING:')
print('Customer ID, Customer Name, Password,
Phone Number, Gender, DOB, Age')
for row in data:
print(row[0],row[1],row[2],row[3],row[4],str(row[5]),row[6],
sep=',')
print('Account Generated')
def delete_customer_account():
cusid=str(input('Enter Customer Id:'))
cuspass=str(input('Enter Customer Password:'))

16 | P a g e
cursor.execute('Use railways;')
l='''Select customer_password from customer
where customer_id = '%s';''' %(cusid,)
cursor.execute(l)
data= cursor.fetchone()
for i in data:
if i == cuspass:
d='''delete from customer
where customer_password = '%s';''' %
(cuspass,)
cursor.execute(d)
railways.commit()
print('Account Deleted')
thank_you_3()
else:
print('Wrong Password or ID')
thank_you_3()
def emp():
func=int(input('''Which function do you want to
perform?-
1.Add trains (Type -> 1)
2.Display trains (Type -> 2)
3.Select trains (Type -> 3)
4.Show Customers (Type -> 4)
5.Show Employees (Type -> 5)
6.Add Stations (Type -> 6)

17 | P a g e
or You want to return to main-menu of the
application (Type -> 0)
Type- '''))
if func == 1:
Add_trains()
elif func == 2:
Display_trains()
elif func == 3:
Select_trains()
elif func == 4:
show_customers()
elif func == 5:
show_employees()
elif func == 6:
add_stations()
elif func == 0:
start()
def thank_you_3():
z=int(input('''Do you want to go to the Main-Menu?
if yes (Type -> '1')
if no (Type -> '0')
Type ->'''))
if z == 1:
start()
else:
print('Thank You')

18 | P a g e
def thank_you():
y=int(input('''Do you want to continue?
if yes (Type -> '1')
if no (Type -> '0')
Type ->'''))
if y == 1:
emp()
else:
print('Thank You')
z=int(input('''Do you want to go to the Main-Menu?
if yes (Type -> '1')
if no (Type -> '0')
Type ->'''))
if z == 1:
start()
else:
print('Thank You')
def put_(a):
b=''
for i in a:
if i != ' ':
b+=i
else:
b+='_'
return b
def Add_trains():

19 | P a g e
cursor.execute("use railways;")
train_no = a = int(input('Enter the Train Number:'))
train_name = b = str(input('Enter the Train Name:'))
from_station = c = str(input('Enter the Name Starting
Station:'))
from_station_code = d = str(input('Enter the Name
Starting Station
Code:'))
to_station = e = str(input('Enter the Name Ending
Station:'))
to_station_code = f = str(input('Enter the Name Ending
Station
Code:'))
insert = '''insert into trains

values({},'{}','{}','{}','{}','{}')'''.format(a,b,c,d,e,f)
cursor.execute(insert)
railways.commit()
cursor.execute("create database %s" %(put_(b),))
cursor.execute("use %s" %(put_(b),))
railways.commit()
train2= mysql.connect(host='localhost', user='root',
password='root',database= put_(b))
cursor3=railways.cursor()
insert3 ='''create table Traininfo(train_no int not null
unique primary key, train_name varchar(255) not null
unique, from_station varchar(255) not null,
from_station_code varchar(255) not null, to_station
varchar(255) not null, to_station_code varchar(255) not
null); '''
cursor3.execute(insert3)
20 | P a g e
train2.commit()
ta='''create table if not exists passenger(passenger_id
int not null unique primary key, passenger_name
varchar(255) not null, gender varchar(1) not null
check(gender in('M','F')), age int not null, Class
varchar(5) not null, seat_no int not null, customer_id
varchar(255) not null, pnrno varchar(255) not null);'''
cursor3.execute(ta)
train2.commit()
insert2 ='''insert into traininfo

values({},'{}','{}','{}','{}','{}')'''.format(a,b,c,d,e,f)
cursor3.execute(insert2)
train2.commit()
cursor3.close()
train2.close()
Add_train_schedule()
thank_you()
def Add_train_schedule():
print('----------> Now you are going to add train
scedule. Please do it carefully and do not make any
mistakes. <----------')
n=int(input('Enter the Number of stations in the
journey (including starting and ending station):'))
j= 'create table Train_Schedule(Station
varchar(255) ,station_code varchar(255) unique primary
key, Arrival_time time, Departure_time time, Day int,
Kilometers int)'
cursor.execute(j)
for i in range(n):
21 | P a g e
print(i+1)
station = str(input('Enter the Name of the
Station:'))
station_code= str(input('Enter the Station code:'))
Arr = str(input('Enter the Arrival time:'))
Dep = str(input('Enter the Departure time:'))
day = int(input('Enter the day (e.g. 1,2,...):'))
kms = int(input('Enter the No. of Kilometers:'))
l='''Insert into Train_Schedule Values
('%s','%s','%s','%s',%s,%s);'''%
(station,station_code,Arr,Dep,day,kms)
cursor.execute(l)
railways.commit()
def Display_trains():
cursor.execute('use railways;')
cursor.execute('select*from trains;')
data=cursor.fetchall()
print('(Train No. , Train Name , From Station , Station
code , To Station , Station code)')
for row in data:
print(row)
thank_you()
def Select_trains():
cursor.execute('''use railways;''')
cursor.execute('Select * from trains')
data=cursor.fetchall()

22 | P a g e
print('(Train No. , Train Name , From Station ,
Station code , To Station , Station code)')
for row in data:
print(row)
num=int(input('Enter the Train No. of the train
which is to be selected:'))
s=''' select train_name from trains
where train_no = %s;''' %(num,)
cursor.execute(s)
t=cursor.fetchone()
for i in t:
u=''' use %s;''' %(put_(i),)
cursor.execute(u)
cursor.execute('Show tables')
k=cursor.fetchall()
for i in k:
for j in i:
print('Option'':', j)
m=str(input('Enter the Option:'))
if m == 'train_schedule':
cursor.execute('''Select * from Train_Schedule
order by Kilometers;''')
data=cursor.fetchall()
print("('Station','Station_code','Arrival
Time','Departure Time','Day','Kilometers')")

23 | P a g e
for row in data:
row2=[row[0],str(row[1]),str(row[2]),str(row[3]),row[4],row
[5]]
print(row2)
print('Please ignore the Arrival and Departure time
of Starting and Ending Station respectively.')
elif m == 'passenger':
cursor.execute('Select * from passenger')
data=cursor.fetchall()
print("('Passenger ID','Passenger
Name','Gender','Age')")
for row in data:
print(row)
elif m == 'traininfo':
cursor.execute('Select * from traininfo')
print('(Train No. , Train Name , From Station ,
Station code , To Station , Station code)')
data=cursor.fetchall()
for row in data:
print(row)
thank_you()
def show_customers():
l='''use railways;'''
m='''select * from customer;'''
cursor.execute(l)
cursor.execute(m)
data=cursor.fetchall()

24 | P a g e
print("('Customer ID','Customer Name','Customer
Password','Phone No.','Gender','DOB','Age')")

for row in data:


row2=[row[0],row[1],row[2],row[3],ro
w[4],str(row[5]),row[6]]
print(row2)
thank_you()
def show_employees():
l='''use railways;'''
m='''select * from emp;'''
cursor.execute(l)
cursor.execute(m)
data=cursor.fetchall()
print("('Employee ID','Employee Name','Employee
Password')")
for row in data:
print(row)
thank_you()
def add_stations():
ta='''create table if not exists
stations( station_name varchar(255) not null, station_code
varchar(255) not null primary key);'''
cursor.execute(ta)
n=int(input('How many New Stations do you want
to add ? (if there are any):'))
for i in range(n):
print(i+1)
staname=str(input('Enter Station Name:'))

25 | P a g e
stacode=str(input('Enter Station Code:'))
l='''insert into stations values ('%s','%s')''' %
(staname,stacode)
cursor.execute(l)
railways.commit()
thank_you()
def customer(cusid):
func=int(input('''Which function do you want to
perform?-
1.Book Ticket (Type -> 1)
2.My Bookings (Type -> 2)
3.PNR Enquiry (Type -> 3)
4.Cancel Ticket (Type -> 4)
5.Chart Vacancy (Type -> 5)
6.View Train Schedule (Type -> 6)
or You want to return to main-menu of the
application(Type -> 0)

Type- '''))
if func == 1:
m='Y'
while m == 'Y':
Book_ticket(cusid)
m=str(input('''Do you want to book more tickets?
If yes (Type->'Y')
If no (Type->'N')
type:'''))

26 | P a g e
elif func == 2:
My_Bookings(cusid)
elif func == 3:
PNR_Enquiry(cusid)
elif func == 4:
Cancel_ticket(cusid)
elif func == 5:
Chart_vacancy(cusid)
elif func == 6:
View_train_schedule(cusid)
elif func == 0:
start()
def thank_you_2(cusid):
y=int(input('''Do you want to continue?
if yes (Type -> '1')
if no (Type -> '0')
Type ->'''))
if y == 1:
customer(cusid)
else:
print('Thank You')
z=int(input('''Do you want to go to the Main-Menu?
if yes (Type -> '1')
if no (Type -> '0')
Type ->'''))
if z == 1:

27 | P a g e
start()
else:
print('Thank You')
def check_2():
r=random.randint(10000,99999)
l='''select passenger_id from passenger where %s''' %
passenger_id= (r)
cursor.execute(l)
d=cursor.fetchone()
if d == None:
return r
else :
check_2()
def Class():
print('Available coaches-')
Class={'First AC':'H','First Class':'F','Executive
Anubhuti':'EA','Executive':'E','Vistadome':'EV','AC 2-
Tier':'A','First AC + AC 2- tier':'B','AC Chair Car':'C','AC 3-tier
Economy':'G','Sleeper':'S','Second sitting':'D','Chair Car': 'J'}
print('[Class:Code:Status]')
for i in Class:
cursor.execute('''Select count(*) from passenger
where Class = '%s' ''' %(Class[i]))
d=cursor.fetchone()
for j in d:
if j < 20:
print(i,':',Class[i],': Available')

28 | P a g e
else:
print(i,':',Class[i],': Fully Booked')
t=str(input('''Enter the desired Class Code,if
available,
else Type-> 'No'
type ->''' ))
return t
def seat_no():
r=random.randint(1,20)
l='''select seat_no from passenger
where seat_no = %s''' %(r)
cursor.execute(l)
d=cursor.fetchone()
if d == None:
return r
else:
seat_no()
def PNRno(cusid,t):
cursor.execute(''' use %s; ''' %(t,))
l='select train_no from traininfo;'
cursor.execute(l)
d=cursor.fetchone()
trano=d[0]
p=str(trano)+ cusid
return p
def Book_ticket(cusid):

29 | P a g e
cursor.execute('Use railways;')
l=''' Select * from stations;'''
cursor.execute(l)
stations= cursor.fetchall()
print('Following are the stations:-')
print('[ Station Name, Station Code]')
for i in stations:
print(i)
from_station=str(input('Enter the Station code of the
desired Starting Station (from above data):'))
to_station=str(input('Enter the Station code of the
desired Ending Station (from above data):'))
l= '''Select * from trains where from_station_code =
'%s' and to_station_code = '%s' ''' %
(from_station,to_station)
cursor.execute(l)
avail_stations= cursor.fetchall()
print('Following are the available trains:-')
print('(Train No. , Train Name , From Station , Station
code , To Station , Station code)')
if avail_stations == []:
print('No Trains Available.')
thank_you_2(cusid)
else:
for i in avail_stations:
print(i)
tno=int(input('Enter the Train Number of the train
you want to book. :'))
30 | P a g e %(tno)
m=''' Select train_name from trains where
train_no = %s;'''
cursor.execute(m)
d=cursor.fetchone()
for i in d:
t=put_(i)
p='''use %s ''' %(t)
cursor.execute(p)
ta='''create table if not exists
passenger( passenger_id int not null unique primary key,
passenger_name varchar(255) not null, gender varchar(1)
not null check(gender in('M','F')), age int not null, Class
varchar(5) not null, seat_no int not null, customer_id
varchar(255) not null, pnrno varchar(255) not null);'''
cursor.execute(ta)
train2= mysql.connect(host='localhost',
user='root', password='root',database='%s' %(t))
cursor2=train2.cursor()
train2.commit()
m='''select count(age) from passenger where
customer_id = '%s';'''%(cusid,)
cursor2.execute(m)
a=cursor2.fetchone()
for i in a:
if i == 6:
print('Maximum limit exceeded.
(Limit=6)')
elif i < 6:
coach= Class()
31 | P a g e
if coach != 'No':
seatno= seat_no()
cid = cusid
pid= check_2()
pname = str(input('Enter Passenger
Name:'))
gender=str(input("Enter Gender ('M' or
'F'):"))
age=int(input('Enter the Age:'))
pnr=PNRno(cusid,t)
s='''insert into passenger values
(%s,'%s','%s',%s,'%s','%s',%s,'%s');'''%
(pid,pname,gender,age,coach, seatno,cid,pnr)
cursor2.execute(s)
train2.commit()
cursor2.execute(''' Select * from
passenger
where passenger_id = %s '''
%(pid))
data=cursor2.fetchall()
print('NOTE:')
print('(Passenger ID, Passenger Name,
Gender, Age, Class, Seat Number,Customer ID,PNR No.)')
for i in data:
print(i)
print('Seat Booked.')
thank_you_2(cusid)
else:

32 | P a g e
thank_you_2(cusid)
def My_Bookings(cusid):
l=''' select train_name from trains;'''
cursor.execute(''' use railways;''')
cursor.execute(l)
trainname=cursor.fetchall()
print('Passenger Info - Train')
for i in trainname:
t=put_(i[0])
cursor.execute('use %s;' %(t,))
m=''' Select * from passenger where
customer_id = %s;''' %(cusid,)
cursor.execute(m)
atad= cursor.fetchall()
for j in atad:
print(j,'-',i[0])
thank_you_2(cusid)
def PNR_Enquiry(cusid):
pnr=str(input('Enter PNR NO.:'))
l=''' select train_name from trains where
train_no = '%s';''' %(pnr[0:5])
cursor.execute(''' use railways;''')
cursor.execute(l)
train=cursor.fetchall()
for i in train:
t=put_(i[0])

33 | P a g e
cursor.execute('use %s;' %(t,))
m=''' Select * from passenger
where pnrno = %s;''' %(pnr)
cursor.execute(m)
atad= cursor.fetchall()
print('Passenger - Status')
for j in atad:
if j != None:
print(j,'-Confirmed')
else:
print('Not Confirmed')
thank_you_2(cusid)
def Cancel_ticket(cusid):
pnr=str(input('Enter PNR NO.:'))
l=''' select train_name from trains where
train_no = '%s';''' %(pnr[0:5])
cursor.execute(''' use railways;''')
cursor.execute(l)
train=cursor.fetchall()
for i in train:
t=put_(i[0])
cursor.execute('use %s;' %(t,))
m=''' Select * from passenger
where pnrno = %s;''' %(pnr)
cursor.execute(m)
atad= cursor.fetchall()

34 | P a g e
print('Passengers')
for j in atad:
print(j)
k = 'Y'
while k =='Y':
pid=str(input('Enter Passenger ID:'))
y=''' delete from passenger where
passenger_id = '%s';'''%(pid,)
train2= mysql.connect(host='localhost',
user='root', password='root',database='%s' %(t))
cursor2= train2.cursor()
cursor2.execute(y)
train2.commit()
print('Cancelled')
k=str(input('''Do you want to cancel more
tickets?
If yes (Type->'Y')
If no (Type->'N')
type:'''))
thank_you_2(cusid)
def Chart_vacancy(cusid):
pnr=str(input('Enter PNR NO.:'))
l=''' select train_name from trains where
train_no = '%s';''' %(pnr[0:5])
cursor.execute(''' use railways;''')
cursor.execute(l)
train=cursor.fetchall()

35 | P a g e
for i in train:
t=put_(i[0])
cursor.execute('use %s;' %(t,))
m=''' select * from passenger;'''
cursor.execute(m)
atad= cursor.fetchall()
print('Passengers')
for j in atad:
print(j)
thank_you_2(cusid)
def View_train_schedule(cusid):
cursor.execute('''use railways;''')
cursor.execute('Select * from trains')
data=cursor.fetchall()
print('(Train No. , Train Name , From Station ,
Station code , To Station , Station code)')
for row in data:
print(row)
num=int(input('Enter the Train No. of the train
which is to be selected:'))
s=''' select train_name from trains
where train_no = %s;''' %(num,)
cursor.execute(s)
t=cursor.fetchone()
for i in t:
u=''' use %s;''' %(put_(i),)

36 | P a g e
cursor.execute(u)
y=''' select * from train_schedule;'''
cursor.execute(y)
q=cursor.fetchall()
print("'Station','Station_code','Arrival
Time','Departure Time','Day','Kilometers'")
for i in q:
print(i[0],i[1],str(i[2]),str(i[3]),i[4],i[5],sep='-')
thank_you_2(cusid)
start()

37 | P a g e
INPUT AND OUTPUT SCREENS
1. Main menu:

2. Employee Login

3. Adding Trains

38 | P a g e
4. Display Trains

5. Creating a customer account

39 | P a g e
6. Login as customer

7. Ticket Booking

40 | P a g e
8. My Booking

9. Ticket Cancelling

41 | P a g e
10. Viewing Train Schedule

42 | P a g e
11. Deleting the account

12. Exiting the application

43 | P a g e
STRUCTURES OF TABLES IN MYSQL
The back end software is MySQL and it contains 4 basic tables.
The tables are in a database made named railways. The 4 tables in
database are:-
1. Customer: - It is a table that stores customer
details like customer id, their name, password,
phone number, gender, Dob and age. It has the
following structure:
Column Name Column Type Constraints
customer_id Int Primary Key
customer_name Varchar(40) Not Null
customer_passwo Varchar(25) Not Null
rd
ph_no Int Not Null
gender Varchar(1) Not Null
DOB date Not Null
age Int Not Null
2. Emp:- It is a table that contains employee
details( employee id, name and password). The
table contains 3 pre-added employees, more
employees can be added. It has the following
structure:
Column Name Column Type Constraints
emp_id int Primary Key
emp_name Varchar(255) Not Null
password Varchar(255) Not Null
3. Stations: - It is a table that contains station name
and station code. The stations are pre-added and
cannot be changed. It has the following structure:
Column Name Column Type Constraints
station_name Varchar(50) Not Null
44 | P a g e
station_code Varchar(29) Primary Key

45 | P a g e
4. Trains: - This table contains details of train like
train number, train name, from and to station and
their station codes. The structure is:
Column Name Column Type Constraints
train_no int Primary Key
train_name varchar(255) Not Null
from_station varchar(255) Not Null
from_station_co varchar(255) Not Null
de
to_station varchar(255) Not Null
to_station_code varchar(255) Not Null

Customer Table:

Emp Table:

46 | P a g e
Stations Table:

Trains Table:

47 | P a g e
BIBLIOGRAPHY
1. Computer Science with Python by Sumita Arora

2. Youtube.com
3. Github.com
4. Stackoverflow.com
5. Python module library
6. Google.com

48 | P a g e

You might also like