KK 2026 Cs
KK 2026 Cs
2024-25
Submitted By:
Class: XII A
S.no. Topic
1. Certificate
2. Acknowledgement
4. Introduction
6. MySql Database
7. Output
8. Bibliography
CERTIFICATE
This is to certify that KARTIKEY and
SHAHID of class: XIi A of ARMY PUBLIC
SCHOOL JODHPUR has done his
project on
RAILWAY RESERVATION SYSTEM under my
supervision. He has taken interest and
has shown at most sincerity in completion
of this project.
I certify this project up to my expectation
& as per guidelines issued by CBSE, NEW
DELHI.
PRINCIPAL
ACKNOWLEDGMENT
It is with pleasure that I acknowledge my
sincere gratitude to our teacher, MRS. MAMTA
PURI who taught and undertook the
responsibility of teaching the subject computer
science. I have been greatly benefited from his
classes.
I am especially indebted to our Principal
MRS. Tabassum Khan who has always been a
source of encouragement and support and
without whose inspiration this project would not
have been a successful I would like to place on
record heartfelt thanks to him.
Finally, I would like to express my sincere
appreciation for all the other students in my
batch their friend & the fine time that we all
shared together.
HARDWARES
1. Desktop / Laptop
2. Mobile Phone
SOFTWARES
1. Python (latest version)
2. MySQL
3. Python Connector Module
INTRODUCTION
The project:- RAILWAY RESERVATION
SYSTEM
Administrative Functions
The Admin Panel, a focal point of the system,
equips administrators with indispensable tools:
User Interaction
User Login: The system provides a secure login interface
for registered users, requiring user ID and password for
access.
Forgot User ID
The `forgot_user_id()` function provides a mechanism for
users to retrieve their registered user IDs via email
verification, ensuring a smooth user experience.
Train Search
The `Train_Search()` function allows users to search for
trains based on origin and destination, providing detailed
information about available trains.
Book Tickets
The `Book_Ticket(uid)` function simulates the ticket booking
process, allowing users to select trains, classes, and
passengers for reservation.
Cancel Tickets
The `Cancel_Ticket()` function facilitates the cancellation of
booked tickets, showcasing the system's ability to handle
modifications to user bookings.
>>>>
import random
from tabulate import tabulate
import mysql.connector as con
dbo=con.connect(host="localhost",user="root",password="admin",database="train_
reservation")
co=dbo.cursor()
#FORGET USER ID
def forgot_user_id():
dbo=con.connect(host="localhost",user="root",password="admin",database="train_
reservation")
co=dbo.cursor()
email=input("Enter your registered email: ")
co.execute("select user_id from user where email_id like '{}'".format(email))
emel=co.fetchall()
for i in emel:
print("Your user_id is: ",(i[0]))
i. # old user id
def old_user():
dbo=con.connect(host="localhost",user="root",password="admin",database="train_
reservation")
co=dbo.cursor()
print("\n---------------------------------------------------------------\n")
uid=input("Enter your user id: ")
co.execute("select user_id from user where user_id like '{}'".format(uid))
b=co.fetchall()
c=len(b)
if c==0:
print("---------------- Your given id is not registered -----------------")
print("\n------------------------------------------------------------------\n")
print("1. Try again")
print("2. Forgot user id")
print("3. Register as a new user")
choose=int(input("Choose an option from above: "))
if choose==1:
old_user()
elif choose==2:
forgot_user_id()
elif choose==3:
new_user()
else:
pas=input("Enter your password: ")
co.execute("select password from user where password like '{}'".format(pas))
n=co.fetchall()
for i in n:
if pas==(i[0]):
print("\n---------------------------------------------------------------\n")
print("-----------Welcome back sir/ma'am what's your plan Today??---------\n")
passenger_panel(uid)
#ADD TRAIN
def add_train():
dbo=con.connect(host="localhost",user="root",password="admin",database="train_
reservation")
co=dbo.cursor()
print("---------------------------------------------------------------------")
a=int(input("Enter train no: "))
b=input("Enter train name: ")
c=input("Enter train origin: ")
d=input("Enter train destination: ")
e=int(input("Enter train journey distance: "))
g=input("Enter train journey time: ")
h=int(input("Enter no of seats in AC: "))
i=int(input("Enter no of seats in SL: "))
j=int(input("Enter no of seats in GEN: "))
k=int(input("Enter price of AC: "))
l=int(input("Enter price of SL: "))
m=int(input("Enter price of GEN: "))
n=input("Enter days available: ")
print("---------------------------------------------------------------------")
co.execute("insert into train_schedule values
({},'{}','{}','{}',{},'{}',{},{},{},{},{},{},'{}')".format(a,b,c,d,e,g,h,i,j,k,l,m,n))
print("*********You have added a new train details successfully************")
dbo.commit()
while True:
# To Update train no
if x==1:
print("---------------------------------------------------------------------")
print("**********YOU ARE GOING TO UPDATE TRAIN NO***********")
tname=input("Enter train name whose no you want to update: ")
tno=int(input("Enter updated train no: "))
co.execute("update train_schedule set train_no={} where train_name='{}'".
format(tno,tname))
print("*******UPDATED SUCCESSFULLY********")
print("---------------------------------------------------------------------")
dbo.commit()
return
i. # To Update train name
elif x==2:
print("---------------------------------------------------------------------")
print("**********YOU ARE GOING TO UPDATE TRAIN NAME***********")
tno=int(input("Enter train no whose name you want to update: "))
tname=input("Enter updated train name: ")
co.execute("update train_schedule set train_name='{}' where train_no={}".
format(tname,tno))
print("*******UPDATED SUCCESSFULLY********")
print("---------------------------------------------------------------------")
dbo.commit()
return
format(tad,tno))
print("*******UPDATED SUCCESSFULLY********")
print("-----------------------------------------------------------------------")
dbo.commit()
return
format(tss,tno))
print("*******UPDATED SUCCESSFULLY********")
print("---------------------------------------------------------------------")
dbo.commit()
return
elif x==13:
print("---------------------------------------------------------------------")
print("**********YOU ARE GOING TO UPDATE FARE PRICE OF GEN***********")
tno=int(input("Enter train no whose fare price of GEN you want to update: "))
tfg=input("Enter updated fare price of GEN: ")
co.execute("update train_schedule set gen_fare={} where train_no={}".
format(tfg,tno))
print("*******UPDATED SUCCESSFULLY********")
print("---------------------------------------------------------------------")
dbo.commit()
return
elif x==14:
print("**********YOU ARE NOW OUT OF UPDATE DETAILS SECTION***********")
break
return
i. #CANCEL TRAIN
def cancel_train():
dbo=con.connect(host="localhost",user="root",password="admin",database
=
"train_reservation")
co=dbo.cursor()
ct=int(input("enter train no which you want to cancel: "))
co.execute("delete from train_schedule where train_no={}".format(ct))
dbo.commit()
print("*********** Train cancelled Successfully ****************")
i. #ADMIN PANEL OPTIONS
. def admin_panel():
while True:
try:
print("------------------------------------------------------
---------------")
print("******Welcome to admin panel******")
print("1. Add train")
print("2. Update details")
print("3. Cancel Train")
print("4. Log out")
opt=int(input("Choose your option: "))
if opt==1:
a. add_train()
elif opt==2:
a. update_details()
elif opt==3:
a. cancel_train()
elif opt==4:
a. print("**********You are out of admin
panel***********")
b. print("------------")
c. main_menu()
except InvalidOptionError as e:
print(f"Error: {e}")
except:
print("**********Choose a correct
option***********")
print("-------"
#PASSENGER PANEL FUNCTIONALITIES
def Train_Search():
dbo=con.connect(host="localhost",user="root",password="admin",database
="train_reservation")
co=dbo.cursor()
o=input("Enter your origin:
")
d=input("Enter your destination: ")
co.execute("select * from train_schedule where origin like '%{}%' and
a=co.fetchall()
for i in a:
print("Train no.: ",a[0][0])
print("Train name: ",a[0][1])
print("Origin: ",a[0][2])
print("Destination: ",a[0][3])
print("Journey distance: ",a[0][4])
print("Available days: ",a[0][12])
print("total time: ",a[0][5])
print("Seats in ac1: ",a[0][6])
print("Seats in sl: ",a[0][7])
print("Seats in GEN: ",a[0][8])
print("Fare of ac1: ",a[0][9])
print("Fare of sl: ",a[0][10])
print("Fare of gen: ",a[0][11])
dbo.commit()
#BOOK TICKETS
def Book_Ticket(uid):
dbo=con.connect(host="localhost",user="root",password="admin",database
=
"train_reservation")
co=dbo.cursor()
print("THIS IS OUR ALL TRAINS AVAILABLE \n ---------------------------------------------
------------------------")
co=dbo.cursor()
pnr=int(input("enter pnr no. you want to cancel: "))
co.execute("delete from booked_tickets where pnr_no={}".format(pnr))
dbo.commit()
print("*********** Your ticket cancelled Successfully ****************")
i. #PASSENGER PANEL
def passenger_panel(uid):
dbo=con.connect(host="localhost",user="root",password="admin",database
=
"train_reservation")
co=dbo.cursor()
while True:
print("---------------------------------------------------------------------")
print("******Welcome to passenger panel******")
print("1. Train Search")
print("2. Book Ticket")
print("3. Cancel Ticket")
print("4. Log out")
choic=int(input("Enter your choice to use: "))
if choic==1:
Train_Search()
elif choic==2:
Book_Ticket(uid)
elif choic==3:
Cancel_Ticket()
elif choic==4:
main_menu()i. #Panel functions
print("*****You are successfully logged out of Passenger panel*****")
print("---------------------------------------------------------------------")
def main_menu():
print("-----------------------------------------------------")
print("********WELCOME TO TRAIN RESERVATION SYSTEM********")
print("1. Admin panel")
print("2. Passenger panel")
print("3. Exit")
ch=int(input("Enter your choice: "))
while True:
if ch==1:
adminpassword()
elif ch==2:
user_panel()
elif ch==3:
print("***** Thank You for using reservation system*****")
print("---------------------------------------------------------------------")
break
main_menu()
MySql DATABASE:-
>>>>
TRAIN TABLE:
PASSENGER LIST :
USER DETAILS :
BOOKED_TICKETS:
TRAIN RESERVATION MAIN PAGE:
OUTPUTS:-
>>>>>
THE ADMIN LOGIN PANEL:
CANCEL TICKET:
BOOKING TICKETS:
SEARCH TRAIN:
BIBILIOGRAPHY:-
3.MySQL
https://www.mysql.com/
4. IRCTC:
https://www.irctc.co.in/nget/
train-search
THANK YOU:
DONE BY :- KARTIKEY
AND SHAHID KHAN