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

computer science project

computer science project (train ticket reservation system)

Uploaded by

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

computer science project

computer science project (train ticket reservation system)

Uploaded by

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

VELAMMAL BODHI CAMPUS - TRICHY

[CBSE IIT/NEET Integrated Senior Secondary School]

CLASS XII

DEPARTMENT OF COMPUTER SCIENCE

2024 – 2025

Name of the Student :


Roll No :
Subject Code :
Name of the Project :
VELAMMAL BODHI CAMPUS - TRICHY
[CBSE IIT/NEET Integrated Senior Secondary School]

DEPARTMENT OF COMPUTER SCIENCE

COMPUTER SCIENCE PROJECT

2024 – 2025

This is to certify that Cadet ______________________________ Roll no.

_______________ has successfully completed the project work entitled

_________________________________________________________________

in the subject Computer Science (083) laid down in the regulations of CBSE

for the purpose of Practical Examination in Class XII to be held in

Velammal Bodhi Campus Trichy on ___________.

INTERNAL EXAMINER EXTERNAL EXAMINER

PRINCIPAL
ACKNOWLEDGEMENT
Apart from the efforts of me, the success of my project depends largely on the
encouragement and guidelines of many others. I take this opportunity to express
my gratitude to the people who have been instrumental in the successful
completion of this project.I express deep sense of gratitude to almighty God for
giving me strength for the successful completion of this project.

I express my heartfelt gratitude to Parents for constant encouragement while


carrying out this project.

I would like to convey my sincere thanks to our Chairman for providing


opportunity for doing this project.

I would like to convey my heartfelt gratitude to our Principal Mrs. Sahana


Rajkumar for tremendous support and guidance.

I would like to convey my heartfelt gratitude to our Headmistress


Mrs. Sudha Navin for providing support and help.

I am overwhelmed to express my thanks to our Higher Secondary


Coordinator Mr. David Gomes for providing support and help.

I would like to express my special thanks to my Guide Mr. S. Vinoth Raj for his
time and efforts provided throughout this project. In this aspect, I am eternally
grateful.

The guidance and support received from all the members who contributed to this
project was vital for the successful completion of my project.

This report is submitted as a part of Practical Examination included in


Curriculum of CBSE for All India Senior Secondary Examination to be held in
the year 2024 – 2025.
TRAIN TICKET RESERVATION SYSTEM
BY
RAHUL KISHORE D

GUIDED BY,
VINOTH RAJ S
TABLE OF CONTENTS
S.NO TOPIC PAGE NO

1 ABSTRACT 01

2 INTRODUCTION 02

SYSTEM REQUIREMENTS
3 3.1 HARDWARE REQUIREMENTS 03
3.2 SOFTWARE REQUIREMENTS
3.3 HOW TO RUN THE PROJECT

4 SOURCE CODE 04

5 OUTPUTS 15

6 CONCLUSION 21

7 BIBLIOGRAPHY 22
ABSTRACT
The "Train Ticket Reservation System Using Python MySQL Connectivity with
Command Line Interface" project aims to provide a user-friendly, efficient, and
automated method for booking train tickets. The system is built using Python as
the primary programming language, with MySQL serving as the database
management system for storing train schedules, passenger details, and ticket
bookings. The command line interface (CLI) allows users to interact with the
system seamlessly, enabling them to perform tasks such as checking train
availability, booking tickets, viewing ticket status, and canceling bookings.

The backend of the system is powered by MySQL, which ensures secure and
reliable data storage. It handles complex operations like searching for trains,
validating user inputs, and updating records. The project employs Python’s
MySQL connector to establish a connection between the application and the
database, ensuring smooth communication and real-time updates.

This system offers a scalable solution for train ticket reservation, focusing on
enhancing accessibility and streamlining the booking process for users. It can be
further developed to incorporate additional features like payment gateways, user
authentication, and integration with railway network APIs for real-time updates.

1
INTRODUCTION
The growing demand for efficient and automated transportation services has led to
the need for digital systems that can simplify the process of ticket reservation and
management. In the context of train travel, passengers often face challenges such
as long queues, manual booking errors, and limited access to information about
train schedules. To address these challenges, the Train Ticket Reservation System
using Python MySQL Connectivity with Command Line Interface (CLI) project is
designed to automate and streamline the entire ticket booking process.

This system provides an intuitive, command-line interface (CLI) that allows users
to check train availability, book tickets, and manage their reservations easily. By
leveraging Python as the programming language, combined with MySQL for data
storage, the system ensures seamless interaction between users and the database.
The MySQL database stores essential information such as train schedules,
available seats, and user details, providing a centralized platform for all ticketing
operations.

The system supports essential functionalities such as viewing available trains,


reserving seats, and canceling bookings. This project focuses on offering a
straightforward, reliable, and scalable solution, suitable for environments where
graphical user interfaces (GUIs) are not feasible or preferred.

The CLI-based approach enhances usability for users with basic computer
knowledge while maintaining flexibility for further development. This system can
be expanded to include features such as online payment gateways, authentication,
and real-time tracking, providing a comprehensive solution for modern train ticket
reservations

2
SYSTEM REQUIREMENTS
MINIMUM HARDWARE REQUIREMENTS:

1. Processor: Intel Core i3 or AMD RYZEN 3 Processors.

2. RAM: 4GB DDR4 RAM

3. Storage: 250GB HDD OR SSD.

4. Display: VGA OR LCD Monitor with Resolution of 1366 x 768 or higher.

5. Peripherals: Standard Keyboard and Optical Mouse. Laser Printer can be


added if in need to take print outs.

MINIMUM SOFTWARE REQUIREMENTS:

1. Python: Version 3.6 or higher.

2. MySQL: MySQL Community Server v8.0.40

3. Code Editor: IDLE or VSCode (recommended)

4. Dependencies: Module: python-connector

5. Operating System: Windows 10 or higher.

HOW TO USE / RUN THE PROJECT

 Install Python: Ensure python 3.6 or above is installed in your system.

 Run the Script: Open the file in IDLE or any code editor and press the run
option to execute the program.

 Output Screen: Follow the menu shown accordingly to do you desired


function.

3
SOURCE CODE:
import mysql.connector as m

def Add_New():

pnr_new = int(input("Enter PNR No: "))

Name_new = input("Enter Train Name: ")

Dept_new = input("Enter Departure: ")

Dest_new = input("Enter Destination: ")

Dept_time = input("Enter Departure Time: ")

ac = int(input("Enter AC Class Fare: "))

f = int(input("Enter 1st Class Fare: "))

s = int(input("Enter 2nd Class Fare: "))

t = int(input("Enter 3rd Class Fare: "))

query = "insert into tt values


(%s,%s,%s,%s,%s,%s,%s,%s,%s)"

cur.execute(query, (pnr_new, Name_new, Dept_new,


Dest_new, Dept_time, ac, f, s, t))

mydb.commit()

print("Train Added Successfully!!")

def Modify_Time():

pnr = int(input("Enter PNR No: "))

Dept_time = input("Enter New Departure Time: ")

4
query2 = "update tt set Dep_Time = %s where pnr = %s"

cur.execute(query2, (Dept_time, pnr))

mydb.commit()

print("Departure Time Modified Successfully!!")

def Modify_Fare():

pnr = int(input("Enter PNR No: "))

New_Fare = int(input("1. AC\n2. 1st Class\n3. 2nd


Class\n4. 3rd Class\nEnter your option: "))

if New_Fare == 1:

ac = int(input("Enter New AC Class Fare: "))

query3 = "update tt set AC = %s where pnr = %s"

cur.execute(query3, (ac, pnr))

print("AC Class Fare Modified Successfully!")

elif New_Fare == 2:

f = int(input("Enter New 1st Class Fare: "))

query4 = "update tt set fc = %s where pnr = %s"

cur.execute(query4, (f, pnr))

print("1st Class Fare Modified Successfully!")

elif New_Fare == 3:

s = int(input("Enter New 2nd Class Fare: "))

query5 = "update tt set sc = %s where pnr = %s"

cur.execute(query5, (s, pnr))

5
print("2nd Class Fare Modified Successfully!")

elif New_Fare == 4:

t = int(input("Enter New 3rd Class Fare: "))

query6 = "update tt set tc = %s where pnr = %s"

cur.execute(query6, (t, pnr))

print("3rd Class Fare Modified Successfully!")

mydb.commit()

def Delete_Schedule():

pnr = int(input("Enter PNR No: "))

fquery = "select * from tt where pnr = %s"

cur.execute(fquery, (pnr,))

data = cur.fetchone()

if data:

delq = "delete from tt where pnr = %s"

cur.execute(delq, (pnr,))

print("Schedule Deleted Successfully!!")

mydb.commit()

else:

print("PNR No. Not Found!!")

def admin_auth(admin):

aname = input("Enter Username: ")


6
apass = input("Emter Password: ")

aq = "select * from admin"

cur.execute(aq)

result = cur.fetchone()

if result[0] == aname and result[1] == apass:

print("Login Successfull")

admin = True

while admin:

adop = int(input("1. Add New Train\n2. Modify


Train Timing\n3. Modify Fare\n4. Delete a Schedule\n5.
Logout\nEnter an Option: "))

if adop == 1:

Add_New()

elif adop == 2:

Modify_Time()

elif adop == 3:

Modify_Fare()

elif adop == 4:

Delete_Schedule()

elif adop == 5:

admin = False

else:

print("Invalid Option")

7
else:

print("Invalid Username or Password")

def Book_Ticket(uname):

p = int(input("Enter PNR: "))

uclass = int(input("1. AC\n2. 1st Class\n3. 2nd


Class\n4. Third Class\nEnter your Option:"))

n = int(input("How many Tickets: "))

qac = "select * from tt where pnr = %s"

cur.execute(qac, (p,))

r = cur.fetchone()

if uclass == 1:

fare = n * r[5]

iq = "insert into tickets values


(%s,%s,%s,%s,%s,%s,%s,%s)"

cur.execute(iq, (uname, p, r[1], r[2], r[3],


r[4], "AC", fare))

print("Ticket Booked Successfully")

elif uclass == 2:

fare = n * r[6]

iq = "insert into tickets values


(%s,%s,%s,%s,%s,%s,%s,%s)"

cur.execute(iq, (uname, p, r[1], r[2], r[3],


r[4], "1st", fare))

8
print("Ticket Booked Successfully")

elif uclass == 3:

fare = n * r[7]

iq = "insert into tickets values


(%s,%s,%s,%s,%s,%s,%s,%s)"

cur.execute(iq, (uname, p, r[1], r[2], r[3],


r[4], "2nd", fare))

print("Ticket Booked Successfully")

elif uclass == 4:

fare = n * r[8]

iq = "insert into tickets values


(%s,%s,%s,%s,%s,%s,%s,%s)"

cur.execute(iq, (uname, p, r[1], r[2], r[3],


r[4], "3rd", fare))

print("Ticket Booked Successfully")

else:

print("Invalid Option")

mydb.commit()

def Cancel_Ticket():

pnr = int(input("Enter PNR: "))

name = input("Enter your username: ")

q = "select * from tickets where pnr = %s and uname =


%s"

9
cur.execute(q, (pnr,name))

r = cur.fetchone()

if r:

iq = "delete from tickets where pnr = %s and


uname = %s"

cur.execute(iq, (pnr, name))

print("Ticket Cancelled Successfully")

else:

print("PNR Not Found")

mydb.commit()

def user_auth(user):

uname = input("Enter Username: ")

upass = input("Emter Password: ")

uq = "select * from users"

cur.execute(uq)

result = cur.fetchone()

if result[0] == uname and result[1] == upass:

print("Login Successfull")

user = True

while user:

10
ops = int(input("1. View Schedule\n2. Book
Ticket\n3. Cancel Ticket\n4. Logout\nEnter your Option:
"))

if ops == 1:

print("Schedule:")

q1 = "select * from tt"

cur.execute(q1)

result = cur.fetchall()

for i in result:

print("PNR: ", i[0])

print("Train Name: ", i[1])

print("Departure: ", i[2])

print("Destination: ", i[3])

print("Departure Time: ", i[4])

print("AC: ", i[5])

print("1st Class: ", i[6])

print("2nd Class: ", i[7])

print("3rd Class: ", i[8])

print()

elif ops == 2:

Book_Ticket(uname)

elif ops == 3:

Cancel_Ticket()

11
elif ops == 4:

user = False

else:

print("Invalid Option")

else:

print("Invalid Username or Password")

def create_user():

nname = input("Enter a user name: ")

npass = input("Enter a password: ")

age = int(input("Enter your age: "))

gender = input("Enter your gender: ")

dob = input("Enter date: yyyy-mm-dd: ")

mob = int(input("Enter Mobile no: "))

loc = input("Enter Location: ")

cq = "insert into users values (%s, %s, %s, %s, %s,


%s, %s)"

cur.execute(cq, (nname, npass, age, gender, dob, mob,


loc))

mydb.commit()

print("User created successfully! Proceed to Login!")

def main():

12
while ch == 'y' or ch == 'Y':

op = int(input("1. Admin\n2. User\n3. New


User\n4. Exit\nEnter Your Option: "))

if op == 1:

admin_auth(admin)

elif op == 2:

user_auth(user)

elif op == 3:

create_user()

elif op == 4:

print("Thank you for using our Service!")

exit(0)

else:

print("Invalid Option. Please try again.")

print("**************************************************
**********************************")

print("****************** Welcome to our Railway


Reservation System ***********************")

print("**************************************************
**********************************")

mydb = m.connect(host = "localhost", user = "root",


passwd = "12345", database = "railway")

13
cur = mydb.cursor()

admin = False

user = False

ch = 'y'

main()

14
OUTPUTS

15
16
17
18
19
20
CONCLUSION
The Train Ticket Reservation System using Python MySQL Connectivity with
Command Line Interface successfully addresses the challenges faced in traditional
train ticket booking processes. By automating ticket reservations through a simple
and intuitive command-line interface, the system offers a more efficient, accurate,
and user-friendly alternative to manual booking. The integration of Python with
MySQL ensures smooth database management, secure data storage, and real-time
updates of train schedules and booking statuses.

This project demonstrates the potential of Python and MySQL in building a


reliable, scalable ticketing system capable of handling a variety of operations,
including reservations, cancellations, and train schedule management. The CLI-
based interface ensures that users can interact with the system easily, even with
minimal technical knowledge.

While the current system provides the basic functionalities required for train ticket
booking, it also serves as a foundation for future enhancements, such as integrating
online payment systems, improving user authentication, and incorporating real-
time tracking of train movements. Overall, this system not only simplifies the
booking process but also provides a model for developing similar applications in
other transportation domains, offering greater convenience and efficiency for
passengers.

21
BIBLIOGRAPHY

22

You might also like