0% found this document useful (0 votes)
15 views3 pages

RR Improved

This document contains source code for a reservation system using Python. It defines functions for booking reservations by inserting records into a MySQL database table, cancelling reservations by deleting records, and displaying records. The code prints menus, gets user input, queries the database, and outputs reservation details. Key aspects include creating a database and table, validating start and end stations, and committing changes to the database.

Uploaded by

satbeersingh2069
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

RR Improved

This document contains source code for a reservation system using Python. It defines functions for booking reservations by inserting records into a MySQL database table, cancelling reservations by deleting records, and displaying records. The code prints menus, gets user input, queries the database, and outputs reservation details. Key aspects include creating a database and table, validating start and end stations, and committing changes to the database.

Uploaded by

satbeersingh2069
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

#SOURCE CODE FOR Reservation system

print("""
___________________________________________________________________________________
________________________
[
]
[
]
[- - - - -W E L C O M E T O N A R M A D A P U R A M R E S E R V A T I O N P
L A T F O R M- - - - -]
[
]
[__________________________________________________________________________________
_______________________]""")

#creating database

import mysql.connector as mc
mydb=mc.connect(host="localhost",user="root",passwd="sjsss")
se="select * from reservation"
mycursor=mydb.cursor()
mycursor.execute("create database if not exists reservation")
mycursor.execute("use reservation")

#creating required tables

mycursor.execute("create table if not exists reservation(name varchar(25) not


null,age varchar(25) not null,gender char(1) not null,start varchar(25),end
varchar(25),status varchar(25) not null)")
mydb.commit()

#Stations

s1='Narmadapuram'
s2='Itarsi Jn'
s3='Pipariya'
s4='Sohagpur'
s5='Bankhedi'
s6='Seoni Malwa'
s7='Babai'
for i in range(1,100):
print("(1) Book Reservation")
print("(2) Cancel Reservation")
print("(3) Display record")
print("(4) Exit")

print('----------------------------------------------------------------------------
----------------------')
ch=int(input("Enter your choice: "))
#PROCEDURE FOR reservation
if(ch==1):
name=str(input("Enter Name: "))
age=str(input("Enter Age: "))
gender=str(input("Enter gender(M/F): "))

print("PLease select your start")


print("1) ",s1)
print("2) ",s2)
print("3) ",s3)
print("4) ",s4)
print("5) ",s5)
print("6) ",s6)
print("7) ",s7)
s=int(input("Enter Start Station: "))

print('----------------------------------------------------------------------------
----------------------')

if(s==1):
s=s1
if(s==2):
s=s2
if(s==3):
s=s3
if(s==4):
s=s4
if(s==5):
s=s5
if(s==6):
s=s6
if(s==7):
s=s7
print("PLease select your destination")
print("1) ",s1)
print("2) ",s2)
print("3) ",s3)
print("4) ",s4)
print("5) ",s5)
print("6) ",s6)
print("7) ",s7)
d=int(input("Enter Destination Station: "))

print('----------------------------------------------------------------------------
----------------------')

if(d==1):
d=s1
if(d==2):
d=s2
if(d==3):
d=s3
if(d==4):
d=s4
if(d==5):
d=s5
if(d==6):
d=s6
if(d==7):
d=s7
mycursor.execute("insert into reservation
values('"+name+"','"+age+"','"+gender+"','"+s+"','"+d+"','"+"Reserved"+"')")
mydb.commit()
print("Your reservation is successful. Please submit online specified
amount on the counter...")

print('----------------------------------------------------------------------------
----------------------')
mycursor.execute("select * from reservation where name='"+name+"' and
age='"+age+"'")
rows=mycursor.fetchall()
for row in rows:
print(row)

print('----------------------------------------------------------------------------
----------------------')
#PROCEDURE FOR CAncelation of reservation
elif(ch==2):
name=str(input("Enter Name: "))
age=str(input("Enter Age: "))
mycursor.execute("delete from reservation where name='"+name+"' and
age='"+age+"'")
mydb.commit()
print("Your Reservation is Successfully Cancelled")

print('----------------------------------------------------------------------------
----------------------')

#PROCEDURE FOR DISPLAYING THE Record of reservation


elif(ch==3):
name=str(input("Enter Name: "))
age=str(input("Enter age: "))
mycursor.execute("select * from reservation where name='"+name+"' and
age='"+age+"'")
rows=mycursor.fetchall()
for row in rows:
print(row)

print('----------------------------------------------------------------------------
----------------------')
else:
break
print('''
_______________________________________________________
[ ]
[- - - - -T H A N K S V I S I T A G A I N- - - - -]
[_____________________________________________________]''')

You might also like