computer science project
computer science project
CLASS XII
2024 – 2025
2024 – 2025
_________________________________________________________________
in the subject Computer Science (083) laid down in the regulations of CBSE
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 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.
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 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:
Run the Script: Open the file in IDLE or any code editor and press the run
option to execute the program.
3
SOURCE CODE:
import mysql.connector as m
def Add_New():
mydb.commit()
def Modify_Time():
4
query2 = "update tt set Dep_Time = %s where pnr = %s"
mydb.commit()
def Modify_Fare():
if New_Fare == 1:
elif New_Fare == 2:
elif New_Fare == 3:
5
print("2nd Class Fare Modified Successfully!")
elif New_Fare == 4:
mydb.commit()
def Delete_Schedule():
cur.execute(fquery, (pnr,))
data = cur.fetchone()
if data:
cur.execute(delq, (pnr,))
mydb.commit()
else:
def admin_auth(admin):
cur.execute(aq)
result = cur.fetchone()
print("Login Successfull")
admin = True
while admin:
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:
def Book_Ticket(uname):
cur.execute(qac, (p,))
r = cur.fetchone()
if uclass == 1:
fare = n * r[5]
elif uclass == 2:
fare = n * r[6]
8
print("Ticket Booked Successfully")
elif uclass == 3:
fare = n * r[7]
elif uclass == 4:
fare = n * r[8]
else:
print("Invalid Option")
mydb.commit()
def Cancel_Ticket():
9
cur.execute(q, (pnr,name))
r = cur.fetchone()
if r:
else:
mydb.commit()
def user_auth(user):
cur.execute(uq)
result = cur.fetchone()
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:")
cur.execute(q1)
result = cur.fetchall()
for i in result:
print()
elif ops == 2:
Book_Ticket(uname)
elif ops == 3:
Cancel_Ticket()
11
elif ops == 4:
user = False
else:
print("Invalid Option")
else:
def create_user():
mydb.commit()
def main():
12
while ch == 'y' or ch == 'Y':
if op == 1:
admin_auth(admin)
elif op == 2:
user_auth(user)
elif op == 3:
create_user()
elif op == 4:
exit(0)
else:
print("**************************************************
**********************************")
print("**************************************************
**********************************")
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.
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