0% found this document useful (0 votes)
31 views36 pages

CS Project ..

Uploaded by

kalaip2007
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)
31 views36 pages

CS Project ..

Uploaded by

kalaip2007
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/ 36

An International CBSE School

(CBSE Affiliation No. 1930312 – New Delhi)


No. 3 Melaiyur, Karuvazhakkarai Post,
Poompuhar Road, Mayiladuthurai District – 609 304.

DEPARTMENT OF COMPUTER SCIENCE

COMPUTER SCIENCE INVESTIGATORY PROJECT


2024 – 2025
Reg. No

This is certified to be the BonafideRecord of work done by

Master/Miss_________________________________________ of Class ________ in the

Computer Science Lab of the School during the year 2024 – 2025.

Submitted for the ALL INDIA SENIOR SECONDARY CERTIFICATE EXAMINATION held

on ___________________ at ALAGU JOTHI ACADEMY.

Teacher In charge Principal

Internal Examiner External Examiner

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 2|Page


CERTIFICATE OF AUTHENTICITY

This is to certify that Master/Miss. ______________________________Student of

Class XII of ALAGUJOTHI ACADEMY- An International CBSE Schoolhas

completed the Investigatory Project on topic

“_________________________________________”under my guidance. This project

is absolutely genuine and does not contain of any plagiarized materials. The references

taken in this project have been declared at the end of this report.

Signature of Teacher-in-charge

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 3|Page


ACKNOWLEDGEMENT

With immense pleasure, I extent my heartfelt thanks to those who helped me to go a long

way in the completion of this investigatory project.

I am also highly indebted to our Computer Science Teacher, Mr. PADMANABHAN .R for

his guidance and constant support throughout the course of this project.

I am also thankful to my parents, the teaching and non – teaching staff of the school for their

timely help.

I also thank our management and our Principal Mr. KALANIDHI.M for providing the

infrastructure and other requirements essential in the successful completion of this project.

Above all I thank almighty who is always there to help me.

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 4|Page


S.NO CONTENTS PG.NO
1 INTRODUCTION 7

2 SOFTWARE AND HARDWARE 8


REQUIRED
3 WHAT IS PYTHON? 9

4 MySQL 9

5 OBJECTIVE 10

6 PYTHON SOURCECODE 14
7 MySQL DATABASE 31

8 OUTPUTS 33

9 BIBLIOGRAPHY 37

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 5|Page


RAILWAY RESERVATION SYSTEM

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 6|Page


INTRODUCTION
Rail transport is one of the important modes of transport in India.
Now a days we see that there are railways that are present for the
long as well as short distance travelling which makes the life of the
people easier. When compared to other means of transport, a
railway is the cheapest means of transport. The maintenance of the
railway database also plays a major role in the smooth running
of this system. The Online Train Ticket Management System will
help in reserving the tickets of the railways to travel from a particular
source to the destination.
This website has various kinds of information that helps
regarding booking of tickets via railways.
Users will be able to search the train availability, the exact fare, the
arrival and departure time of the train and they can also book the
ticket by using the debit, credit or master card and after booking the
ticket if the user wants to cancel it then they can easily do it also.
This system is designed to provide the facility where the customer
can easily book tickets online. The main advantage of this project is
here customer don’t have to stand in long queues for buying a ticket.
Customer can purchase ticket through online anytime. This Train
Ticket Booking System is the mini project developed using java and
MySQL.
The customer needs to register to the website before booking train
ticket. Customer can book the ticket, view previous transaction, print
ticket receipt after the login. The passenger can select source location
and destination location to book the train ticket. While booking ticket
the system asked payment card details for transaction.

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 7|Page


SOFTWARES AND HARDWARES
REQUIRED;
SOFTWARES
◈.Python
◈.MySQL
◈.Python connector Module

HARDWARES
◈.Desktop/laptop
◈.Mobile Phone

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 8|Page


WHAT IS PYTHON?
Python is commonly used for developing websites and software, task
automation,
data analysis, and data visualization. Since it’s relatively easy to
learn, Python has
been adopted by many non-programmers such as accountants and
scientists, for a
variety of everyday tasks, like organizing finances.
What can you do with python?
1. Data analysis and machine learning
2. Web development
3. Automation or scripting
4. Software testing and prototyping

MySQL
A relational database stores data in separate tables rather than
putting all the data in one big storeroom. This adds speed and
flexibility. The SQL part of"MySQL" stands for "Structured Qucry
Language." SQL is the most common standardized language used to
access databases and is defined by the ANSI/ISO SQL Standard. The
SQL standard has been evolving since 1986 and several versions
exist. In this manual, " SOL-92" refers to the standard released in
1992, "SQL:1999* refers to the standard released in 1999, and
"SQL:2003"refers to the current version of the standard.

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 9|Page


Objectives of the Project
1.Administrative Empowerment;
The core objectives of our project are multi-faceted, addressing the
intricate needs of both administrators and passengers within the
railway ecosystem.

User Registration & Authentication;


The project introduces a streamlined User Registration process,
requiring users to provide essential details such as user ID, name,
phone number, email ID, and password. This information is securely
stored in a MySQL database. Additionally, robust User
Authentication mechanisms ensure the security and integrity of user
accounts.

Administrative Functions;
The Admin Panel, a focal point of the system, equips administrators
with indispensable tools;
Add Train: Administrators can add new trains to the system,
specifying crucial details such as train number, name, origin,
destination, journey distance, journey time, seat availability, and
fares.
Update Train Details: The system allows administrators to modify
existing train details, adapting to dynamic demands and operational
changes. This includes updating seat availability, journey details, and
fare information.
Cancel Train: In response to operational constraints or changing
demands, administrators have the authority to cancel trains,
ensuring flexibility and adaptability in the system.
CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 10 | P a g e
2. Enhancing Customer Experience;
The Customer Panel is designed with the end-user in mind, focusing
on providing an intuitive and user-friendly interface for seamless
ticket booking and management.

User Interaction
User Login: The system provides a secure login interface for
registered users, requiring user ID and password for access.
Forgot User ID: Users can retrieve forgotten user IDs through their
registered email addresses, enhancing user experience and reducing
barriers to access.

Passenger Panel Functionalities


The Passenger Panel, an extension of the Customer Panel, offers a
range of functionalities:
Train Search: Users can search for trains based on origin and
destination, providing comprehensive details about available trains,
schedules, seat availability, and fares.
Book Tickets: The system facilitates the ticket booking process,
allowing users to select trains, classes, and passengers for
reservation.
Cancel Tickets: A streamlined process enables users to cancel
booked tickets, providing flexibility and convenience in managing
travel plans.

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 11 | P a g e


Key Code Functionalities Integrated
User Management Functions;
New User Registration;
The “new_user()” function employs a systematic approach to
register new users, generating a unique user ID and storing essential
details in the MySQL database.
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.
Old User Authentication;
The “old_user()” function verifies user credentials, allowing access
to registered users and guiding them through the system
functionalities.
Admin Panel Operations;
Admin Password Verification;
The “adminpassword()” function implements a secure password
system for accessing the admin panel, ensuring restricted access and
system security.
Train Management Operations;
Functions such as “add_train()”, “update_details()”, and
“cancel_train()” constitute essential operations within the Admin
Panel. These functionalities empower administrators to add new
trains, update train details, and cancel trains when necessary.

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 12 | P a g e


Passenger Panel Operations
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.

Significance of the Project


The significance of our project extends beyond its technical
complexity; it lies in its real-world applicability. In a world where
efficient transportation is vital, an effective railway reservation
system is crucial. The project addresses the pressing need for
systems that can adapt to the evolving demands of the railway
industry while prioritizing user satisfaction, security, and
transparency.

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 13 | P a g e


PYTHON SOURCE CODE;
1. import random

2. from tabulate import tabulate

3. import mysql.connector as con

4. dbo=con.connect(host="localhost",user="root",password="admin",database="train_

reservation")

5. co=dbo.cursor()

i. #NEW USER REGISTRATION SECTION

6. def new_user():

7. dbo=con.connect(host="localhost",user="root",password="admin",database="train_

reservation")

8. co=dbo.cursor()

9. import random

10. pid=random.randint(0,1000)*10

11. print("----------------------------------------------------------------------")

12. print(" \n Welcome to our reservation system \n Register Yourself here to use our

system")

13. uid=input("Enter your user id: ")

14. name=input("Enter your name: ")

15. pno=input("Enter your phone no: ")

16. eid=input("Enter your email_id: ")

17. pwd=input("Enter your password: ")

18. co.execute("insert into user values

('{}',{},'{}',{},'{}','{}')".format(uid,pid,name,pno,eid,pwd))

19. print("************* Congratulations!!! Your id is successfully created **************")

20. print("----------------------------------------------------------------------")

21. dbo.commit()

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 14 | P a g e


i. #FORGET USER ID

22. def forgot_user_id():

23. dbo=con.connect(host="localhost",user="root",password="admin",database="train_

reservation")

24. co=dbo.cursor()

25. email=input("Enter your registered email: ")

26. co.execute("select user_id from user where email_id like '{}'".format(email))

27. emel=co.fetchall()

28. for i in emel:

29. print("Your user_id is: ",(i[0]))

i. # old user id

30. def old_user():

31. dbo=con.connect(host="localhost",user="root",password="admin",database="train_

reservation")

32. co=dbo.cursor()

33. print("\n---------------------------------------------------------------\n")

34. uid=input("Enter your user id: ")

35. co.execute("select user_id from user where user_id like '{}'".format(uid))

36. b=co.fetchall()

37. c=len(b)

38. if c==0:

39. print("---------------- Your given id is not registered -----------------")

40. print("\n------------------------------------------------------------------\n")

41. print("1. Try again")

42. print("2. Forgot user id")

43. print("3. Register as a new user")

44. choose=int(input("Choose an option from above: "))

45. if choose==1:

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 15 | P a g e


46. old_user()

47. elif choose==2:

48. forgot_user_id()

49. elif choose==3:

50. new_user()

51. else:

52. pas=input("Enter your password: ")

53. co.execute("select password from user where password like '{}'".format(pas))

54. n=co.fetchall()

55. for i in n:

56. if pas==(i[0]):

a. print("\n---------------------------------------------------------------\n")

b. print("-----------Welcome back sir/ma'am what's your plan Today??---------\n")

c. passenger_panel(uid)

i. #PASSWORD FUNCTION FOR ACCESS TO USER PANEL

57. def user_panel():

58. print(" 1. Register")

59. print(" 2. Login")

60. print(" 3. Back")

61. out=int(input("Enter your choice: "))

62. if out==1:

63. new_user()

64. elif out==2:

65. old_user()

66. elif out==3:

67. main_menu()

i. #PASSWORD FUNCTION FOR ACCESS TO ADMIN FUNCTION

68. def adminpassword():

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 16 | P a g e


69. password=(input("Enter your password: "))

70. if password=="CLASS12CS":

71. print("******************Access Granted********************")

72. print("---------------------------------------------------------------------")

73. admin_panel()

74. else:

75. print("***************ACCESS NOT GRANTED ENTER CORRECT

PASSWORD************")

76. print("---------------------------------------------------------------------")

77. adminpassword()

i. #ADD TRAIN

78. def add_train():

79. dbo=con.connect(host="localhost",user="root",password="admin",database="train_

reservation")

80. co=dbo.cursor()

81. print("---------------------------------------------------------------------")

82. a=int(input("Enter train no: "))

83. b=input("Enter train name: ")

84. c=input("Enter train origin: ")

85. d=input("Enter train destination: ")

86. e=int(input("Enter train journey distance: "))

87. g=input("Enter train journey time: ")

88. h=int(input("Enter no of seats in AC: "))

89. i=int(input("Enter no of seats in SL: "))

90. j=int(input("Enter no of seats in GEN: "))

91. k=int(input("Enter price of AC: "))

92. l=int(input("Enter price of SL: "))

93. m=int(input("Enter price of GEN: "))

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 17 | P a g e


94. n=input("Enter days available: ")

95. print("---------------------------------------------------------------------")

96. co.execute("insert into train_schedule values

({},'{}','{}','{}',{},'{}',{},{},{},{},{},{},'{}')".format(a,b,c,d,e,g,h,i,j,k,l,m,n))

97. print("*********You have added a new train details successfully************")

98. dbo.commit()

i. #UPDATE TRAIN TABLE

99. def update_details():

100.dbo=con.connect(host="localhost",user="root",password="admin",database=

"train_reservation")

101.co=dbo.cursor()

102.print("---------------------------------------------------------------------")

103.print("******Welcome to update train system******")

104. print("1. Update train no")

105. print("2. Update train name")

106. print("3. Update train origin")

107. print("4. Update train destination")

108. print("5. Update journey dist")

109. print("6. Update available days")

110. print("7. Update journey time")

111. print("8. Update no of seats in AC")

112. print("9. Update no of seats in SL")

113. print("10. Update no of seats in GEN")

114. print("11. Update price of AC")

115. print("12. Update price of SL")

116. print("13. Update price of GEN")

117. print("14. Exit")

118. x=int(input("Enter your choice to use: "))

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 18 | P a g e


119. while True:

i. # To Update train no

120. if x==1:

121. print("---------------------------------------------------------------------")

122. print("**********YOU ARE GOING TO UPDATE TRAIN NO***********")

123. tname=input("Enter train name whose no you want to update: ")

124. tno=int(input("Enter updated train no: "))

125. co.execute("update train_schedule set train_no={} where train_name='{}'".

format(tno,tname))

126. print("*******UPDATED SUCCESSFULLY********")

127. print("---------------------------------------------------------------------")

128. dbo.commit()

129. return

i. # To Update train name

130. elif x==2:

131. print("---------------------------------------------------------------------")

132. print("**********YOU ARE GOING TO UPDATE TRAIN NAME***********")

133. tno=int(input("Enter train no whose name you want to update: "))

134. tname=input("Enter updated train name: ")

135. co.execute("update train_schedule set train_name='{}' where train_no={}".

format(tname,tno))

136. print("*******UPDATED SUCCESSFULLY********")

137. print("---------------------------------------------------------------------")

138. dbo.commit()

139. return

i. # To Update train origin

140. elif x==3:

141. print("---------------------------------------------------------------------")

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 19 | P a g e


142. print("**********YOU ARE GOING TO UPDATE TRAIN ORIGIN***********")

143. tno=int(input("Enter train no whose origin you want to update: "))

144. orgn=input("Enter updated train origin: ")

145. co.execute("update train_schedule set origin='{}' where train_no={}".

format(orgn,tno))

146. print("*******UPDATED SUCCESSFULLY********")

147. print("---------------------------------------------------------------------")

148. dbo.commit()

149. return

i. # To Update train destination

150. elif x==4:

151. print("---------------------------------------------------------------------")

152. print("**********YOU ARE GOING TO UPDATE TRAIN DESTINATION***********")

153. tno=int(input("Enter train no whose destination you want to update: "))

154. td=input("Enter updated train destination: ")

155. co.execute("update train_schedule set destination='{}' where train_no={}".

format(td,tno))

156. print("*******UPDATED SUCCESSFULLY********")

157. print("---------------------------------------------------------------------")

158. dbo.commit()

159. return

i. # To Update journey distance

160. elif x==5:

161. print("---------------------------------------------------------------------")

162. print("**********YOU ARE GOING TO UPDATE JOURNEY DISTANCE ***********")

163. tno=int(input("Enter train no whose journey dist you want to update: "))

164. tjd=input("Enter updated journey dist: ")

165. co.execute("update train_schedule set journey_distance='{}' where

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 20 | P a g e


train_no={}". format(tjd,tno))

166. print("*******UPDATED SUCCESSFULLY********")

167. print("---------------------------------------------------------------------")

168. dbo.commit()

169. return

i. # To Update the days train is available

170. elif x==6:

171. print("---------------------------------------------------------------------")

172. print("**********YOU ARE GOING TO UPDATE AVAILABLE DAYS***********")

173. tno=int(input("Enter train no whose avl_days you want to update: "))

174. tad=input("Enter updated available days: ")

175. co.execute("update train_schedule set avl_days ='{}' where train_no={}".

format(tad,tno))

176. print("*******UPDATED SUCCESSFULLY********")

177. print("-----------------------------------------------------------------------")

178. dbo.commit()

179. return

i. # To Update journey time

180. elif x==7:

181. print("---------------------------------------------------------------------")

182. print("**********YOU ARE GOING TO UPDATE JOURNEY TIME***********")

183. tno=int(input("Enter train no whose journey_time you want to update: "))

184. tj=input("Enter updated journey time: ")

185. co.execute("update train_schedule set total_time='{}' where train_no={}".

format(tj,tno))

186. print("*******UPDATED SUCCESSFULLY********")

187. print("---------------------------------------------------------------------")

188. dbo.commit()

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 21 | P a g e


189. return

i. # To Update no of seats in ac coach of that train

190. elif x==8:

191. print("---------------------------------------------------------------------")

192. print("**********YOU ARE GOING TO UPDATE SEATS IN AC***********")

193. tno=int(input("Enter train no whose no of seats in AC you want to update: "))

194. tsa=input("Enter updated no of seats in AC: ")

195. co.execute("update train_schedule set ac1='{}' where train_no={}".

format(tsa,tno))

196. print("*******UPDATED SUCCESSFULLY********")

197. print("---------------------------------------------------------------------")

198. dbo.commit()

199. return

i. # To Update no of seats in SL coach of that train

200. elif x==9:

201. print("---------------------------------------------------------------------")

202. print("**********YOU ARE GOING TO UPDATE SEATS IN SL***********")

203. tno=int(input("Enter train no whose no of seats in Sl you want to update: "))

204. tss=input("Enter updated no of seats in Sl: ")

205. co.execute("update train_schedule set sl='{}' where train_no={}".

format(tss,tno))

206. print("*******UPDATED SUCCESSFULLY********")

207. print("---------------------------------------------------------------------")

208. dbo.commit()

209. return

i. # To Update no of seats in GEN coach of that train

210. elif x==10:

211. print("---------------------------------------------------------------------")

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 22 | P a g e


212. print("**********YOU ARE GOING TO UPDATE SEATS IN GEN***********")

213. tno=int(input("Enter train no whose no of seats in GEN you want to update: "))

214. tsg=input("Enter updated no of seats in GEN: ")

215. co.execute("update train_schedule set gen='{}' where train_no={}".

format(tsg,tno))

216. print("*******UPDATED SUCCESSFULLY********")

217. print("---------------------------------------------------------------------")

218. dbo.commit()

219. return

i. # To Update fare price of AC of that train

220. elif x==11:

221. print("---------------------------------------------------------------------")

222. print("**********YOU ARE GOING TO UPDATE FARE PRICE OF AC***********")

223. tno=int(input("Enter train no whose fare price of ac you want to update: "))

224. tfa=input("Enter updated fare price of ac: ")

225. co.execute("update train_schedule set ac_fare={} where train_no={}".

format(tfa,tno))

226. print("*******UPDATED SUCCESSFULLY********")

227. print("---------------------------------------------------------------------")

228. dbo.commit()

229. return

i. # To Update fare price of SL of that train

230. elif x==12:

231. print("---------------------------------------------------------------------")

232. print("**********YOU ARE GOING TO UPDATE FARE PRICE OF SL***********")

233. tno=int(input("Enter train no whose fare price of SL you want to update: "))

234. tfs=input("Enter updated fare price of SL: ")

235. co.execute("update train_schedule set sl_fare={} where train_no={}".

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 23 | P a g e


format(tfs,tno))

236. print("*******UPDATED SUCCESSFULLY********")

237. print("---------------------------------------------------------------------")

238. dbo.commit()

239. return

i. # To Update fare price of GEN of that train

240. elif x==13:

241. print("---------------------------------------------------------------------")

242. print("**********YOU ARE GOING TO UPDATE FARE PRICE OF GEN***********")

243. tno=int(input("Enter train no whose fare price of GEN you want to update: "))

244. tfg=input("Enter updated fare price of GEN: ")

245. co.execute("update train_schedule set gen_fare={} where train_no={}".

format(tfg,tno))

246. print("*******UPDATED SUCCESSFULLY********")

247. print("---------------------------------------------------------------------")

248. dbo.commit()

249. return

250. elif x==14:

251. print("**********YOU ARE NOW OUT OF UPDATE DETAILS SECTION***********")

252. break

253. return

i. #CANCEL TRAIN

254. def cancel_train():

255. dbo=con.connect(host="localhost",user="root",password="admin",database=

"train_reservation")

256. co=dbo.cursor()

257. ct=int(input("enter train no which you want to cancel: "))

258. co.execute("delete from train_schedule where train_no={}".format(ct))

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 24 | P a g e


259. dbo.commit()

260. print("*********** Train cancelled Successfully ****************")

i. #ADMIN PANEL OPTIONS

261. def admin_panel():

262. while True:

263. try:

264. print("---------------------------------------------------------------------")

265. print("******Welcome to admin panel******")

266. print("1. Add train")

267. print("2. Update details")

268. print("3. Cancel Train")

269. print("4. Log out")

270. opt=int(input("Choose your option: "))

271. if opt==1:

a. add_train()

272. elif opt==2:

a. update_details()

273. elif opt==3:

a. cancel_train()

274. elif opt==4:

a. print("**********You are out of admin panel***********")

b. print("---------------------------------------------------------------------")

c. main_menu()

275. except InvalidOptionError as e:

276. print(f"Error: {e}")

277. except:

278. print("**********Choose a correct option***********")

279. print("---------------------------------------------------------------------")

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 25 | P a g e


i. #PASSENGER PANEL FUNCTIONALITIES

280. def Train_Search():

281. dbo=con.connect(host="localhost",user="root",password="admin",database=

"train_reservation")

282. co=dbo.cursor()

283. o=input("Enter your origin: ")

284. d=input("Enter your destination: ")

285. co.execute("select * from train_schedule where origin like '%{}%' and

destination like '%{}%'".format(o,d))

286. a=co.fetchall()

287. for i in a:

288. print("Train no.: ",a[0][0])

289. print("Train name: ",a[0][1])

290. print("Origin: ",a[0][2])

291. print("Destination: ",a[0][3])

292. print("Journey distance: ",a[0][4])

293. print("Available days: ",a[0][12])

294. print("total time: ",a[0][5])

295. print("Seats in ac1: ",a[0][6])

296. print("Seats in sl: ",a[0][7])

297. print("Seats in GEN: ",a[0][8])

298. print("Fare of ac1: ",a[0][9])

299. print("Fare of sl: ",a[0][10])

300. print("Fare of gen: ",a[0][11])

301. dbo.commit()

i. #BOOK TICKETS

302. def Book_Ticket(uid):

303. dbo=con.connect(host="localhost",user="root",password="admin",database=

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 26 | P a g e


"train_reservation")

304. co=dbo.cursor()

305. print("THIS IS OUR ALL TRAINS AVAILABLE \n ---------------------------------------------------------------------")

306. op="select train_no,train_name,origin,destination from train_schedule"

307. co.execute(op)

308. r=co.fetchall()

309. columns=[i[0] for i in co.description]

310. print(tabulate(r,headers=columns,tablefmt="fancy_grid"))

311. print("---------------------------------------------------------------------\n\n")

312. trainno=int(input("Enter your Train no: "))

313. tcktno=int(input("Enter no of seats you want to book: "))

314. print("1. AC TICKET")

315. print("2. SL TICKET")

316. print("3. GEN TICKET")

317. typ=int(input("Enter your choice of class: "))

318. if typ==1:

319. a=co.execute("select ac1_fare from train_schedule where

train_no={}".format(trainno))

320. b=co.fetchall()

321. print(b[0][0])

322. elif typ==2:

323. a=co.execute("select sl_fare from train_schedule where

train_no={}".format(trainno))

324. b=co.fetchall()

325. print(b[0][0])

326. elif typ==3:

327. a=co.execute("select gen_fare from train_schedule where

train_no={}".format(trainno))

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 27 | P a g e


328. b=co.fetchall()

329. print(b[0][0])

330. for i in range (tcktno):

331. cus1=input("Enter customer name: ")

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

333. print("--------------- For gender M=Male, F=Female, O=Other ------------------")

334. gender=input("Enter your gender: ")

335. j=random.randint(100000,999999)

336. print("Your PNR no is: ",j)

337. cnf="Confirmed"

338. p=b[0][0]

339. co.execute("insert into booked_tickets values

('{}',{},{},'{}',{},'{}',{},'{}')".format(uid,j,trainno,cus1,age,gender,p,cnf))

340. p=b[0][0]

341. amt=tcktno*p

342. print("Your total ticket price is: ",amt)

343. dbo.commit()

344. def Cancel_Ticket():

345. dbo=con.connect(host="localhost",user="root",password="admin",database=

"train_reservation")

346. co=dbo.cursor()

347. pnr=int(input("enter pnr no. you want to cancel: "))

348. co.execute("delete from booked_tickets where pnr_no={}".format(pnr))

349. dbo.commit()

350. print("*********** Your ticket cancelled Successfully ****************")

i. #PASSENGER PANEL

351. def passenger_panel(uid):

352. dbo=con.connect(host="localhost",user="root",password="admin",database=

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 28 | P a g e


"train_reservation")

353. co=dbo.cursor()

354. while True:

355. print("---------------------------------------------------------------------")

356. print("******Welcome to passenger panel******")

357. print("1. Train Search")

358. print("2. Book Ticket")

359. print("3. Cancel Ticket")

360. print("4. Log out")

361. choic=int(input("Enter your choice to use: "))

362. if choic==1:

363. Train_Search()

364. elif choic==2:

365. Book_Ticket(uid)

366. elif choic==3:

367. Cancel_Ticket()

368. elif choic==4:

369. main_menu()

370. print("*****You are successfully logged out of Passenger panel*****")

371. print("---------------------------------------------------------------------")

i. #Panel functions

372. def main_menu():

373. print("-----------------------------------------------------")

374. print("********WELCOME TO TRAIN RESERVATION SYSTEM********")

375. print("1. Admin panel")

376. print("2. Passenger panel")

377. print("3. Exit")

378. ch=int(input("Enter your choice: "))

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 29 | P a g e


379. while True:

380. if ch==1:

381. adminpassword()

382. elif ch==2:

383. user_panel()

384. elif ch==3:

385. print("***** Thank You for using reservation system*****")

386. print("---------------------------------------------------------------------")

387. break

388. main_menu()

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 30 | P a g e


MySQL DATABASE;
TRAIN TABLE:

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 31 | P a g e


USER DETAILS:

BOOKED TICKETS:

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 32 | P a g e


OUTPUTS:
TRAIN RESERVATION MAIN PAGE:

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 33 | P a g e


THE ADMIN LOGIN PANEL:

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 34 | P a g e


CANCEL TICKET:

BOOOKING TICKETS:

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 35 | P a g e


SEARCH TRAIN:

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 36 | P a g e


BIBLIOGRAPHY
◇CLASS 11TH & 12TH COMPUTER SCIENCE
BOOK (SUMITA ARORA)
◇PYTHON- HHTPS://WWW.PYTHON.ORG/
◇MySQL - HHTPS://WWW.MYSQL.COM/

CLASS XII COMPUTER SCIENCE INVESTIGATORY PROJECT 2024-2025 37 | P a g e

You might also like