computerscienceprojectofrailwayreservationsystempythonprogramming-230627100223-c244d621 (1)
computerscienceprojectofrailwayreservationsystempythonprogramming-230627100223-c244d621 (1)
1
Kankarbagh, Patna - 800020
PROJECT REPORT
On
RAILWAY RESERVATION
SYSTEM
ACADEMIC SESSION
2024-2025
SUBJECT
COMPUTER SCIENCE (083)
Prepared By :
1. Harshit kumar
CERTIFICATE
This is to certify that HARSHIT KUMAR of
Class XII, has completed his project entitled
“RAILWAY RESERVATION SYSTEM” under my
supervision for the subject “COMPUTER
SCIENCE(083) ” for All India Secondary School
Examination 2024-2025.
He has taken proper care and shown utmost
sincerity in the completion of this project. I certify
that this project is up to my expectation and as per
the guidelines issued by CBSE.
DR.INDRAJEER KR
MP.SINGH
H.O.D (Computer Science) Principal
Kv No.1 kankarbagh, Kv No.1 Kankarbagh,
Patna Patna
ACKNOWLEDGEMENT
Firstly, I would like to express my special thanks of
gratitude to my principal SH. MP. SINGH , who gave
me this opportunity to work on this project. I would
like to thank her for the completion of this project.
2 REQUIREMENTS
2-3
3 PROGRAMMING
LANGUAGE & 4
CONCEPTS USED
4 PACKAGES,
MODULES AND 5-7
FUNCTIONS USED
5 DATABASE & TABLES
USED 8-11
6 SCOPE OF THE
PROJECT 12-13
7 PROJECT CODE
14-30
8 SCREENSHOTS OF THE
OUTPUT 31-34
INTRODUCTION TO THE
PROJECT
SOFTWARE REQUIREMENTS:
• A window based operating system with DOS
support
• The system must be connected with a LAN
connection
PROCESSOR REQUIREMENTS:
MEMORY REQUIREMENTS:
OTHER REQUIREMENTS:
• MySql version 5.7
• Python version 3.10.5
• MySql connectivity
• MS Word 2010
PROGRAMING
LANGUAGE
FUNCTIONS USED
PACKAGE MODULE FUNTION DESCRIPTION
NAME NAME S
Used to
random generate a
randint() Pnr number in
Nil a given range
To make a
mysql. connect() connection
between mysql
connector and python
It provides a
cursor() cursor object
for the working
of the database
through
It regulates
menu() activities like
signup, signin
in the project
User also show the
defined account details
functions of the user
This function is
ticket_boo for the booking
king() of the ticket for
train
This function is
delhi() for the fare of
the train delhi
express
This function is
sabarmati for the fare of
() the train
sabarmati
express
goa() This function is
for the fare of
the train goa
express
chennai() This function is
for the fare of
the train
chennai
express
ticket_che This function is
cking() for the checking
for the booked
tickets
User ticket_can This function is
Defined celling() for the
functions cancellation of
the booked
tickets
checking_ This function is
2() for the deletion
of existing user
account
checking_ This function is
1() for creating a
new account in
the project
checking() This function is
used for logging
in of an existing
account in
project
checking_ This function is
3() for checking
our personal
account details
Used for
displaying the
tabulate() data in a
tabular format
tabulate
DATABASE & TABLES
USED
The Database used in this project is
RAILWAY104
TABLE FIELD DATA TYPE DESCRIPTION
NAME NAME
fname varchar(100) Stores the first
name of the
user
lname varchar(100) Stores the last
name of the
user
User_
user_ varchar(100) Stores the
accounts name username of
the user
password Varchar(100) Stores the
password for
the account of
the user
phno Varchar(15) Stores the
phone no. of
the user
gender Varchar(50) Stores the
gender of the
user
dob Varchar(50) Stores the
date of birth of
the user
age Varchar(4) Stores the age
of the user
TABLE FILED DATA TYPE DESCRIPTION
NAME NAME
TRAIN_ Varchar(30) Stores the
NAME train name
given by the
user
TRAIN_NO Varchar(20) Stores the
train no
given by the
Train_ user
details Source Varchar(30) Stores the
starting point
or location of
the train
Destination Varchar(30) Stores the
destination
of the train
AC1 Varchar(20) Stores the AC1
fare of the
ticket
AC2 Varchar(20) Stores the AC2
fare of the
AC3 Varchar(20) Stores the AC3
fare of the
ticket
You can log out your account with this project and
also can delete the existing account that you have
made
MAIN CODE:-
import random import
mysql.connector
mycon=mysql.connector.connect(host='localhost',user='roo
t',p asswd='akshat@123',database='railway104')
cursor=mycon.cursor() mycon.autocommit=True
from tabulate import tabulate
def menu():
ch=1
while ch==1:
print('\t\t-------WELECOME TO ONLINE RAILWAY
RESERVATION SYSTEM-------\t\t')
print('1.SIGN IN')
print('2.SIGN UP')
print('3.DELETE ACCOUNT')
print('4.EXIT')
ch1=int(input('ENTER YOUR CHOICE:'))
if ch1==1:
a=checking()
if a==True:
print('WELCOME')
main()
else:
continue elif
ch1==2:
a=checking_1()
if a==True:
main() else:
print('PASSWORD ALREADY EXISTS')
continue
elif ch1==3:
c=checking_2()
if c==True:
print('ACCOUNT DELETED')
continue else:
print('YOUR PASSWAORD OR USER_NAME IS
INCORRECT')
continue
elif ch1==4:
print('THANK YOU')
break else:
print('ERROR 404:PAGE NOT FOUND')
break
print('1.YES')
print('2.NO')
ch=int(input('DO YOU WANT TO CONTINUE OR NOT:'))
def main():
print('1.YES')
print('2.NO')
c=int(input("DO YOU WANT TO CONTINUE OR NOT:"))
while (c==1):
print(' 1.TICKET BOOKING',"\n", '2.TICKET
CHECKING',"\n",'3.TICKET CANCELLING',"\n",'4.ACCOUNT
DETAILS',"\n",'5.LOG OUT')
ch=int(input('enter ur choice:'))
if ch==1:
ticket_booking()
elif ch==2:
ticket_checking()
elif ch==3:
ticket_cancelling()
elif ch==4:
checking_3()
elif
ch==5:
print('THANK YOU')
break else:
print('WRONG INPUT')
else:
print('ERROR 404: ERROR PAGE NOT FOUND')
def ticket_booking():
mycon.autocommit=True
print("******AVAILABLE
TRAINS******") g="select*from
train_details" cursor.execute(g)
data=cursor.fetchall()
Data=list(data)
a=['TRAIN_NAME','TRAIN_NO','SOURCE','DESTINATION','AC1'
,'AC2','AC3','SLEEPER']
print(tabulate(data,headers=a,tablefmt="psql"))
print("2365.DELHI EXPRESS")
print("3425.GOA EXPRESS")
print("1267.CHENNAI EXPRESS")
print("2564.SABARMATI EXPRESS")
x=input("ENTER THE TRAIN NO. FOR MORE TICKET
OPTIONS:")
n=int(input("HOW MANY TICKETS YOU WANT\n(YOU CAN
BOOK ONLY 2 TICKETS):"))
if n<=2:
if
x=='2365':
g=delhi()
h="JAIPUR"
c1="DELHI"
c2="DELHI
EXPRESS"
elif x=='3425':
g=goa() h="GOA"
c1="AGRA" c2="GOA
EXPRESS" elif x=='1267':
g=chennai()
h="CHENNAI"
c1="DELHI"
c2="CHENNAI EXPRESS"
elif x=='2564':
g=sabarmati()
h="GUJARAT"
c1="AGRA"
c2="SABARMATI EXPRESS"
else:
print("INVALID OPTION")
pnrno=random.randint(1000,3000)
for i in range (n):
b=input("ENTER THE PERSON'S NAME:")
c=input("ENTER THE AGE:")
print(' M=MALE','\n','F=FEMALE','\n','N=NOT TO
MENTION')
v={'m':'MALE','f':'FEMALE','n':'NOT TO MENTION'}
s=input("ENTER THE GENDER:")
s2="insert into railway
values('{}','{}',
{},'{}','{}','{}','{}','{}','{}','{}')".format(pnrno,b,c,x,c2,s,g
[1]
,c1,h,g[0])
cursor.execute(s2)
print('BOOKED SUCCESSFULLY')
print("YOUR PNR NO. GENERATED IS :",pnrno)
else:
print("MORE THAN 2 TICKETS ARE NOT ALLOWED")
def delhi():
x=input("ENTER YOUR CHOICE OF
TICKET(AC1/AC2/AC3/SLEEPER):")
if(x=='ac1'):
print ("YOU HAVE Chosen FIRST CLASS AC TICKET")
s=6000 elif (x=='ac2'):
print ("YOU HAVE Chosen SECOND CLASS AC TICKET")
s=5000 elif (x=='ac3'):
print ("YOU HAVE Chosen THIRD CLASS AC TICKET")
s=4000 elif (x=='sleeper'):
print ("YOU HAVE Chosen SLEEPER TICKET")
s=3000 else:
print("Invalid option")
print("YOUR TICKET PRICE FOR EACH IS ",s,"\n")
return s,x
def sabarmati():
x=input("ENTER YOUR CHOICE OF
TICKET(AC1/AC2/AC3/SLEEPER):")
if(x=='ac1'):
print ("YOU HAVE Chosen FIRST CLASS AC TICKET")
s=9000 elif (x=='ac2'):
print ("YOU HAVE Chosen SECOND CLASS AC TICKET")
s=8000 elif (x=='ac3'):
print ("YOU HAVE Chosen THIRD CLASS AC TICKET")
s=7000 elif (x=='sleeper'):
print ("YOU HAVE Chosen SLEEPER TICKET")
s=5000 else:
print("Invalid option")
print("YOUR TOTAL TICKET PRICE FOR EACH IS ",s,"\n")
return s,x
def goa():
x=input("ENTER YOUR CHOICE OF
TICKET(AC1/AC2/AC3/SLEEPER):")
if(x=='ac1'):
print ("YOU HAVE Chosen FIRST CLASS AC TICKET")
s=10000 elif (x=='ac2'):
print ("YOU HAVE Chosen SECOND CLASS AC TICKET")
s=9000 elif (x=='ac3'):
print ("YOU HAVE Chosen THIRD CLASS AC TICKET")
s=8000 elif (x=='sleeper'):
print ("YOU HAVE Chosen SLEEPER TICKET")
s=7000 else:
print("Invalid option")
print("YOUR TOTAL TICKET PRICE FOR EACH IS ",s,"\n")
return s,x
def chennai():
x=input("ENTER YOUR CHOICE OF
TICKET(AC1/AC2/AC3/SLEEPER):") if(x=='ac1'):
print ("YOU HAVE Chosen FIRST CLASS AC TICKET")
s=12000 elif (x=='ac2'):
print ("YOU HAVE Chosen SECOND CLASS AC TICKET")
s=10000 elif (x=='ac3'):
print ("YOU HAVE Chosen THIRD CLASS AC TICKET")
s=9000 elif (x=='sleeper'):
print ("YOU HAVE Chosen SLEEPER TICKET")
s=7000 else:
print("Invalid option")
print("YOUR TOTAL TICKET PRICE FOR EACH IS ",s,"\n")
return s,x
def ticket_checking():
print('1.yes')
print('2.no')
def ticket_cancelling():
print('1.yes')
print('2.no')
ch=int(input("WANT TO CANCEL A TICKET:"))
if ch==1:
pnrno=input('ENTER THE PNR NO:')
s1="delete from railway where
pnr_no='{}'".format(pnrno) cursor.execute(s1)
print('TICKET CANCELLED') elif ch==2:
print('THANK YOU')
else:
print('ERROR 404:PAGE NOT FOUND')
def checking_2():
a=input('USER NAME:')
b=input('PASS WORD:')
try:
s1="select user_name from user_accounts
where password='{}'".format(b)
cursor.execute(s1) data=cursor.fetchall()[0]
data=list(data) if data[0]==a:
print('IS THIS YOUR ACCOUNT')
s1="select user_name from user_accounts where
password='{}'".format(b)
c1="select fname,lname from user_accounts
where password='{}'".format(b)
cursor.execute(c1) data1=cursor.fetchall()[0]
data1=list(data1) data1=data1[0]+' '+data1[1]
cursor.execute(s1) data=cursor.fetchall()[0]
data=list(data) if data[0]==a:
x=['FIRST NAME','LAST NAME','PHONE
NUMBER','GENDER','DATE OF BIRTH','AGE']
s1="select fname,lname,phno,gender,dob,age
from user_accounts where password='{}'".format(b)
cursor.execute(s1)
data=cursor.fetchall()
[0] data=list(data)
for i in range(0,6):
print(x[i],':::',data[i])
print('1.yes')
print('2.no')
vi=int(input('enter your choice:'))
if vi==1:
b1="delete from user_accounts where
password
= '{}'".format(b)
cursor.execute(b1
) return True
elif vi==2:
print('SORRY,RETRY')
else:
print('ERROR 404:PAGE NOT FOUND')
else:
return False
except:
print('ACCOUNT DOES NOT EXIST')
def checking_1():
f=input("FIRST NAME\t\t:")
l=input("LAST NAME \t\t:")
n=f+" "+l
a=input('USER NAME \t\t:')
b=input('PASS WORD \t\t:') c=input('RE-
ENTER YOUR PASS WORD :')
ph=input("PHONE NUMBER\t\t:")
print(' M=MALE','\n','F=FEMALE','\n','N=NOT TO
MENTION')
gen=input('ENTER YOUR GENDER\t:')
print("ENTER YOR DATE OF BIRTH")
d=input("Date(DD) :")
o=input("Month(MM) :")
p=input("Year(YYYY) :")
dob=d+'/'+o+'/'+p age=input('YOUR
AGE \t\t:')
v={'m':'MALE','f':'FEMALE','n':'NOT TO
MENTION'} if b==c: try:
c1="insert into user_accounts
values('{}','{}','{}','{}','{}','{}','{}','{}')".format(f,l,a,b,ph,
v[gen],dob,age) cursor.execute(c1)
print('WELCOME',f,' ',l) return True except:
print('PASSWORD ALREADY EXISTS')
return False else:
print('BOTH PASSWORDS ARE NOT MATCHING')
def checking():
a=input('USER NAME:')
b=input('PASS WORD:') try:
def checking_3():
a=input('USER NAME:')
b=input('PASS WORD:')
try:
s1="select user_name from user_accounts where
password='{}'".format(b)
c1="select fname,lname from user_accounts
where password='{}'".format(b)
cursor.execute(c1) data1=cursor.fetchall()[0]
data1=list(data1) data1=data1[0]+' '+data1[1]
cursor.execute(s1) data=cursor.fetchall()[0]
data=list(data) if data[0]==a:
x=['FIRST NAME','LAST NAME','PHONE
NUMBER','GENDER','DATE OF BIRTH','AGE']
s1="select fname,lname,phno,gender,dob,age from
user_accounts where password='{}'".format(b)
cursor.execute(s1) data=cursor.fetchall()
data=list(data)
print(tabulate(data,headers=x,tablefmt="psql"))
else:
return False
except:
print('ACCOUNT DOES NOT EXIST')
menu()
SCREENSHOTS OF
OUTPUT
SIGNING UP FOR A NEW ACCOUNT:-