0% found this document useful (0 votes)
15 views22 pages

Railway Reservation Project

The document is a project file for a Railway Reservation System created by a senior secondary student at Sardar Patel Vidyalaya. It includes sections such as candidate declaration, acknowledgements, project aim, Python and MySQL integration, source code, and bibliography. The project aims to automate the reservation process, provide real-time information, and improve customer experience through a user-friendly digital platform.

Uploaded by

mohitpal782007
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)
15 views22 pages

Railway Reservation Project

The document is a project file for a Railway Reservation System created by a senior secondary student at Sardar Patel Vidyalaya. It includes sections such as candidate declaration, acknowledgements, project aim, Python and MySQL integration, source code, and bibliography. The project aims to automate the reservation process, provide real-time information, and improve customer experience through a user-friendly digital platform.

Uploaded by

mohitpal782007
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/ 22

SARDAR PATEL VIDYALAYA

I-13, SEC-25, YEIDA, GAUTAM BUDDHA NAGAR


A
PROJECT FILE
On
“RAILWAY RESERVATION SYSTEM”
SENIOR SECONDARY CLASS (2024-25)

Submitted by:

Supervisor:

Mr. Pawan Kumar


CONTENTS

 Candidate Declaration

 Acknowledgement

 Certificate

 Aim of Project

 Python Features Incorporated

 Source Code

 Output

 Bibliography
SARDAR PATEL VIDYALAYA
Candidate’s Declaration

I hereby certify that the work embodied in this project file entitled “Railway
Reservation System” by_______________, In partial fulfilment of the
requirements for the award of senior secondary class submitted to the School of
Sardar Patel Vidyalaya is an authentic record of my own work carried out under
the supervision of Mr. Pawan Kumar.

[ ]

This is to certify that the above statement made by the candidate is correct to the
best of my knowledge and belief.

Principal
Ms. Harvinder Kaur
Sardar Patel Vidyalaya,
Sec-25, YEIDA, Gautam Buddha Nagar

[Mr. Pawan Kumar]


[PGT-CS]
Sardar Patel Vidyalaya,
Sec-25, YEIDA, Gautam Buddha Nagar
ACKNOWLEDGEMENT

I would like to express my sincere gratitude to my Computer Science teacher


Mr. Pawan Kumar for introducing me to this topic and encouraging me to carry
out with the project. I would like to thank her for giving me guidance and moral
support, all throughout this academic year. This project has given me a deeper
understanding of the subject.
Secondly, I would like to extend my gratitude to the principal ma’am
Ms. Harvinder Kaur who gave me this golden opportunity to do this wonderful
project.
I would like to thank my parents for providing me with the required resources and
encouragement for the completion of this project.

[ ]
CERTIFICATE

This is to certify that ____________ of class XII-Science of Sardar Patel


Vidyalaya has satisfactorily completed the project under the supervision of
Mr. Pawan Kumar and has taken proper care and shown utmost sincerity in
completion of this project as per the CBSE guidelines.

[Mr. Pawan Kumar]


INTRODUCTION TO PYTHON AND MYSQL
Python is a flexible, portable, easy to learn and modifiable language. So, we are
integrating MYSQL with Python interface for executing any database applications.

The several reasons to use Python programming for database applications


are:

 Programming in Python is arguably more efficient and faster compared to other


languages.
 Python is famous for its popularity.
 It is platform-independent.
 Python supports SQL cursors.
 In many programming languages, the application developer needs to take care
of the open and closed connections of the database to avoid further exceptions
and errors. In Python, these connections are taken care of.
 Python supports relational database system.
 Python database APIs are compatible with various databases, so it is very easy
to migrate and port database application interfaces.
MySQL is an open – source and freely available Relational Database Management
System (RDBMS) that uses Structured Query Language (SQL), It provides
excellent features for creating, storing, maintaining and accessing data stored in the
form of databases and their respective tables. A single MySQL database can store
several tables at a time and can store thousands of records in it.

Advantages of MySQL:

 Reliability and performance


 Modifiable
 Multi-Platform Support
 Powerful Processing Capabilities
 Integrity (Checks)
 Authorization
 Powerful Language
 Reliable
 Freedom of Data Abstraction
 Complete Language for a Database
MYSQL AND PYTHON CONNECTIVITY
Install MySQL in Windows
Download MySQL database exe from official site and install as usual normal
installation of software in Windows. Refer this tutorial, for a step by step guide.

How to Install MySQL Connector Library for Python


Here is how to connect MySQL with Python:

For Python 2.7 or lower install using pip as:

pip install mysql-connector

For Python 3 or higher version install using pip3 as:

pip3 install mysql-connector

Test the MySQL Database connection with Python


To test MySQL database connectivity in Python here, we will use pre-installed
MySQL connector and pass credentials into connect() function like host, username
and password as shown in the below Python MySQL connector example.

HARDWARE AND SOFTWARE REQUIREMENTS

 PYTHON INBUILT FUNCTIONS


 WINDOWS 7/8/10
 RAM 512 TO 4 GB
 HDD 40 GB TO 1 TB
 PYTHON 3.6 TO 3.8
 MYSQL SERVER 5.0 TO 3.8
 MYSQL CONNECTIVITY
 FLOW OF CONTROL
AIM OF RAILWAY RESERVATION PROJECT:
The aim of a Railway Reservation Project is to develop an efficient, user-friendly
system for managing and facilitating train travel reservations. Key objectives
typically include:

1. Automating the Reservation Process: Simplifying the booking of tickets for


passengers by providing a digital platform for users to easily check availability,
book seats, and make payments.
2. Real-Time Information: Offering real-time updates about train schedules, seat
availability, cancellations, delays, and other relevant information, ensuring
passengers have up-to-date details.
3. Efficient Seat Management: Optimizing the allocation of available seats on
trains, ensuring that passengers are assigned appropriate seats based on
availability and preferences.
4. Simplifying Ticketing: Enabling passengers to book tickets for both short and
long-distance travel with ease, while integrating features for selecting train
classes (e.g. AC, first-class), and even cancellation and refund processing.
5. User Accessibility: Ensuring the system is accessible to all users, including
mobile users, through web-based and mobile applications, making the
reservation process available anytime, anywhere.
6. Payment Integration: Supporting secure payment methods to process ticket
payments online, ensuring convenience and security for passengers.
7. Improving Customer Experience: Providing a seamless and efficient travel
experience for passengers by offering features like ticket booking history,
reminders, and customer support.
8. Managing Train Schedules and Routes: Ensuring accurate scheduling and
routing of trains, with updates and adjustments based on demand, capacity, and
operational changes.
SOURCE CODE
Now we create database using database programming in
Python:

import mysql.connector

import os

import platform

#import pandas as pd

pnr=1024

mydb=mysql.connector.connect(host="localhost",user="root",passwd="root");

mycursor=mydb.cursor()

#CREATING DATABASE AND TABLE

def dataBase():

mycursor.execute("create database if not exists Railway_Syatem")

mycursor.execute("use Railway_Syatem")

railresmenu()

def Tables():

print(" Creating Train detail table")

sql = "CREATE TABLE if not exists traindetail (\

tname varchar(30) ,\

tnum int,\
ac1 int,\

ac2 int ,\

ac3 int ,\

slp int);"

mycursor.execute(sql)

print(" Traindetail Table created")

print(" Creating Passengers table")

sql = "CREATE TABLE if not exists Passengers (\

pname char(25) ,\

age char(3) ,\

trainno char(15) NOT NULL , \

noofpas int(3) ,\

cls char(5) ,\

amt int ,\

status varchar(10) ,\

pnrno int);"

mycursor.execute(sql)

print(" Passengers table created")

railresmenu()

def railresmenu():
print("1. Access DataBase")

print("2. Create Tables if not Exist")

print("---------Railway Reservation------------ ")

print("3.Train Detail")

print("4.Reservation of Ticket")

print("5.Cancellation of Ticket")

print("6.Display PNR status")

print("7.Quit")

n=int(input("enter your choice"))

if(n==1):

dataBase()

elif(n==2):

Tables()

elif(n==3):

traindetail()

elif(n==4):

reservation()

elif(n==5):

cancel()

elif(n==6):

displayPNR()

elif(n==7):
exit(0)

else:

print("wrong choice")

def traindetail():

print("Train Details")

ch='y'

while (ch=='y'):

l=[]

name=input("enter train name :")

l.append(name)

tnum=int(input("enter train number :"))

l.append(tnum)

ac1=int(input("enter number of AC 1 class seats"))

l.append(ac1)

ac2=int(input("enter number of AC 2 class seats"))

l.append(ac2)

ac3=int(input("enter number of AC 3 class seats"))

l.append(ac3)

slp=int(input("enter number of sleeper class seats"))

l.append(slp)

train=(l)
sql="insert into
traindetail(tname,tnum,ac1,ac2,ac3,slp)values(%s,%s,%s,%s,%s,%s)"

mycursor.execute(sql,train)

mydb.commit()

print("insertion completed")

print("Do you want to insert more train Detail")

ch=input("enter yes/no")

print('\n' *3)

print("======================================================
=============")

railresmenu()

def reservation():

global pnr

l1=[]

pname=input("enter passenger name=")

l1.append(pname)

age=input("enter age of passenger =")

l1.append(age)

trainno=input("enter train number")

l1.append(trainno)

np=int(input("Enter number of passanger:"))

l1.append(np)
print("select a class you would like to travel in")

print("1.AC FIRST CLASS")

print("2.AC SECOND CLASS")

print("3.AC THIRD CLASS")

print("4.SLEEPER CLASS")

cp=int(input("Enter your choice:"))

if(cp==1):

amount=np*1000

cls='ac1'

elif(cp==2):

amount=np*800

cls='ac2'

elif(cp==3):

amount=np*500

cls='ac3'

else:

amount=np*350

cls='slp'

l1.append(cls)

print("Total amount to be paid:",amount)

l1.append(amount)

pnr=pnr+1

print("PNR Number:",pnr)
print("status: confirmed")

sts='conf'

l1.append(sts)

l1.append(pnr)

train1=(l1)

sql="insert into
passengers(pname,age,trainno,noofpas,cls,amt,status,pnrno)values(%s,%s,%s,%s,
%s,%s,%s,%s)"

mycursor.execute(sql,train1)

mydb.commit()

print("insertion completed")

print("Go back to menu")

print('\n' *10)

print("======================================================
=============")

railresmenu()

def cancel():

print("Ticket cancel window")

pnr=input("enter PNR for cancellation of Ticket")

pn=(pnr,)

sql="update passengers set status='deleted' where pnrno=%s"


mycursor.execute(sql,pn)

mydb.commit()

print("Deletion completed")

print("Go back to menu")

print('\n' *10)

print("======================================================
=============")

railresmenu()

def displayPNR():

print("PNR STATUS window")

pnr=input("enter PNR NUMBER")

pn=(pnr,)

sql="select * from passengers where pnrno=%s"

mycursor.execute(sql,pn)

res=mycursor.fetchall()

print("PNR STATUS are as follows : ")

print("(pname,age,trainno, noofpas,cls,amt,status, pnrno)")

for x in res:

print(x)

print("Go back to menu")


print('\n' *3)

print("======================================================
=============")

railresmenu()
OUTPUT:
BIBLIOGRAPHY

 Sumita Arora text book class XI

 Sumita Arora text book class XII

 https:/www.geeksforgeeks.org

 https://pynative.com

 https://stackoverflow.com

You might also like