Railway Management
Railway Management
Railway Management
connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="database")
mycursor=mydb.cursor()
pnr=1024
mydb=mysql.connector.connect(host="localhost",user="root",passwd="database",database="rail");
mycursor=mydb.cursor()
mydb=mysql.connector.connect(host="localhost",user="root",passwd="database",database="rail");
mycursor=mydb.cursor()
def railresmenu():
print("1.Train Detail")
print("2.Reservation of Ticket")
print("3.Cancellation of Ticket")
print("5.Quit")
if(n==1):
traindetail()
elif(n==2):
reservation()
elif(n==3):
cancel()
elif(n==4):
displayPNR()
elif(n==5):
exit(0)
else:
print("wrong choice")
def traindetail():
print("Train Details")
ch='y'
while (ch=='y'):
l=[]
l.append(name)
l.append(tnum)
l.append(ac1)
l.append(ac2)
l.append(ac3)
l.append(slp)
train=(l)
mydb.commit()
print("insertion completed")
ch=input("enter yes/no")
print("===================================================================")
railresmenu()
def reservation():
global pnr
l1=[]
l1.append(pname)
l1.append(age)
l1.append(trainno)
l1.append(np)
print("4.SLEEPER CLASS")
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)
l1.append(amount)
pnr=pnr+1
print("PNR Number:",pnr)
print("status: confirmed")
sts='conf'
l1.append(sts)
l1.append(pnr)
train1=(l1)
mycursor.execute(sql,train1)
mydb.commit()
print("insertion completed")
railresmenu()
railresmenu()
def cancel():
pn=(pnr,)
mycursor.execute(sql,pn)
mydb.commit()
print("Deletion completed")
print("===================================================================")
railresmenu()
railresmenu()
def displayPNR():
pn=(pnr,)
mycursor.execute(sql,pn)
res=mycursor.fetchall()
#mydb.commit()
for x in res:
print(x)
#print("Deletion completed")
print("===================================================================")
railresmenu()
railresmenu()
railresmenu()