-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrailway2[1].py
More file actions
351 lines (234 loc) · 7.83 KB
/
railway2[1].py
File metadata and controls
351 lines (234 loc) · 7.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# this section is for connection of mysql table to python
def www():
try:
a=input('enter your host')
b=input('enter your password')
c=input('enter your root')
import mysql.connector
yj=mysql.connector.connect(host=a,user=c,password=b)
return yj
except:
print('your password,username,host is worng')
www()
# calling the function www
db=www()
# defining the cursor
cur=db.cursor()
# defining the function which is used for udate the booed ticket
def update():
def bv():
print('a.kerala express')
print('b.shatabdi express')
print('c.back to menu')
o=input('ENTER YOUR TRAIN')
g=o.lower()
return g
# calling the function bv
uc=bv()
if uc=='a':
cur.execute('select Sno from kerala')
for i in cur:
print(' Sno. is ',i)
a=int(input('ENTER YOUR SNO. NUMBER AS 1/2/3/4...'))
zc=int(input('ENTER YOUR NEW SNO.'))
b=input('ENTER YOUR NEW NAME')
c=int(input('ENTER YOUR NEW PHONE NO.'))
d=input('ENTER YOUR NEW CLASS')
e=int(input('ENTER YOUR NO. OF PASEENGER'))
f=input('ENTER YOUR NEW LOCATION')
g=input('ENTER YOUR NEW DESTINATION')
rp=60*e
query="update kerala set Sno=%s,Name='%s',phoneno=%s,class='%s',passenger=%s,yourlocation='%s',destination='%s',Rs=%s where Sno=%s"%(zc,b,c,d,e,f,g,rp,a)
cur.execute(query)
db.commit()
print(' *********√your ticket is updated********')
elif uc=='b':
cur.execute('select Sno from shatabdi')
for i in cur:
print('SNO. IS ',i)
ap=int(input('ENTER YOUR SNO. NUMBER AS 1/2/3...'))
zc=int(input('ENTER YOUR NEW SNO.'))
bp=input('ENTER YOUR NEW NAME')
cp=int(input('ENTER YOUR NEW PHONE NO.'))
dp=input('ENTER YOUR NEW CLASS')
ep=int(input('ENTER YOUR NEW NO. OF PASEENGER'))
fp=input('ENTER YOUR NEW LOCATION')
gp=input('ENTER YOUR NEW DESTINATION')
rj=67*ep
querys="update shatabdi set Sno=%s, Name='%s',phoneno=%s,class='%s',passenger=%s,yourlocation='%s',destination='%s',Rs=%s where Sno=%s"%(zc,bp,cp,dp,ep,fp,gp,rj,ap)
cur.execute(querys)
db.commit()
print(' **********√your ticket is updated**********')
elif uc=='c':
railway()
else:
print('*********PLEASE ENTER CORRECT CHOICE*********')
bv()
# defining the function for cancelling the ticket
def cancel():
y=input('did you want to agree to cancel Y/N')
j=y.lower()
if j=='y':
# taking the data of user to cancel the ticket
print('a. CANCEL TICKET FOR KERALA')
print('b.CANCEL TICKET FOR SHATABDI')
print('c.back to the menu')
n=input('ENTER YOUR TRAIN')
qp=n.lower()
# for checking the ticket
if qp=='a':
cur.execute('select Sno from kerala')
for i in cur:
print(i)
f=int(input('ENTER YOUR SNO FOR DELELTE AS 1/2/3/4...'))
cur.execute('delete from kerala where sno=%s'%f)
db.commit()
print(' ******your kerala train ticket is cancel now*******')
if qp=='b':
cur.execute('select Sno from shatabdi')
for i in cur:
print(i)
f=int(input('ENTER YOUR SNO FOR DELELTE AS 1/2/3/4...'))
cur.execute('delete from shatabdi where sno=%s'%f)
db.commit()
print(' ******your shatabdi train ticket is cancel now*******')
if qp=='c':
railway()
else:
print(' ********ok your ticket is not cancel*******')
# after the cancelling the ticket then call the railway function
railway()
# this function for checking the train for booking
def rails():
print("a.FOR CHECKING KERALA EXPRESS")
print("b.FOR CHECKING SHATABDI EXPRESS")
print('c.for back to menu')
w=input('enter your choice')
if w=='a':
cur.execute('select Sno from kerala')
for i in cur:
print('your Sno. is',i)
d=input('ENTER YOUR SNO. as 1/2/3/4...')
cur.execute('select*from kerala where Sno=%s'%(d,))
for i in cur:
print(i)
rails()
elif w=='b':
cur.execute('select Sno from shatabdi')
for i in cur:
print('your Sno. is',i)
q=input('ENTER YOUR SNO. as1/2/3/4....')
cur.execute('select*from shatabdi where Sno=%s'%(q,))
for i in cur:
print(i)
rails()
elif w=='c':
railway()
else:
print('please enter your choice')
rails()
# this function for giving the searched train
def rail(FR,des):
def traink():
print('Searching for the train...')
print('*****no. of train are available****')
print(' **a.Kerala Express**')
print(' **b.Shatabdi Express**')
print(' **c.back for menu')
ch=input('enter your choice')
return ch
chs=traink()
if chs=='a':
try:
a=int(input('ENTER SNO. NUMBER'))
b=input('ENTER YOUR NAME')
c=int(input('ENTER YOUR PHONE NO.'))
d=input('ENTER YOUR CLASS')
e=int(input('ENTER YOUR NO. OF PASEENGER'))
i=60*e
query="insert into kerala values(%s,'%s',%s,'%s',%s,'%s','%s',%s)"%(a,b,c,d,e,FR,des,i)
cur.execute(query)
print(' *****√ your booking is successfull')
db.commit()
traink()
except:
print('********PLEASE ENTER YOUR CORRECT INFORMATION********')
traink()
elif chs=='b':
try:
a=int(input('ENTER SNO. NUMBER'))
b=input('ENTER YOUR NAME')
c=int(input('ENTER YOUR PHONE NO.'))
d=input('ENTER YOUR CLASS')
e=int(input('ENTER YOUR NO. OF PASEENGER'))
l=67*e
query="insert into shatabdi values(%s,'%s',%s,'%s',%s,'%s','%s',%s)"%(a,b,c,d,e,FR,des,l)
cur.execute(query)
print(' *****√ your booking is successfull')
db.commit()
traink()
except:
print('******PLEASE ENTER YOUR CORRECT INFORMATION******')
traink()
elif chs=='c':
# calling the railway funcion
railway()
else:
print()
traink()
try:
cur.execute('create database railway')
cur.execute('use railway')
q="create table kerala(Sno integer primary key,Name varchar(15) NOT NULL,phoneno integer NOT NULL,class varchar(25) NOT NULL,passenger integer NOT NULL,yourlocation varchar(12) NOT NULL,destination varchar(12) NOT NULL,Rs integer)"
cur.execute(q)
p="create table shatabdi(Sno integer primary key,Name varchar(15) NOT NULL,phoneno integer NOT NULL,class varchar(25) NOT NULL,passenger integer NOT NULL,yourlocation varchar(12) NOT NULL,destination varchar(12) NOT NULL,Rs integer)"
cur.execute(p)
railway()
except:
cur.execute('use railway')
# for defining the railway function for taking the data
def railway():
print('*******WELCOME TO THE TRAIN RESERVATION*******')
print(' ***********menu************')
print(' *******a.BOOKING FOR THE TRAIN*******')
print(' *******b.CHECKING THE TRAIN*******')
print(' *******c.CANCEL FOR TICKET*******')
print(' *******d.FOR UPDATE YOUR TICKET*******')
print(' *******e.EXIST*******')
choice=input('ENTER YOUR CHOICE')
choices=choice.lower()
if choices=='a':
u=input('will you want booking a ticket Y/N')
k=u.lower()
if k=='y':
FR=input('ENTER YOUR PLACE')
des=input('ENTER YOUR DESTINATION')
rail(FR,des)
if choices=='b':
rails()
if choices=='c':
cancel()
if choices=='d':
x=input('did you want update your ticket Y/N')
m=x.lower()
if m=='y':
update()
# this is for existing from railway file
if choices=='e':
print('existing...')
def xc():
wc=input('did you to open Y/N')
sc=wc.lower()
if sc=='y':
railway()
elif sc=='n':
xc()
else:
print('*****PLEASE ENTER CORRECT CHOICE FROM Y/N*****')
xc()
xc()
else:
print('***********PLEASE ENTER YOUR CORRECT CHOICE*************')
railway()
# calling the function railway for restart
railway()