0% found this document useful (0 votes)
28 views

Main Program

The document describes a Python program that allows users to book movie tickets through an interactive menu. It connects to a MySQL database called 'Theatre' and allows the user to choose between booking tickets, visiting the box office, or selecting seats in the 1st or 2nd class. Depending on their choice, the user is prompted to enter movie, customer and payment details, which are then inserted into the appropriate database table.

Uploaded by

meena jayaraman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Main Program

The document describes a Python program that allows users to book movie tickets through an interactive menu. It connects to a MySQL database called 'Theatre' and allows the user to choose between booking tickets, visiting the box office, or selecting seats in the 1st or 2nd class. Depending on their choice, the user is prompted to enter movie, customer and payment details, which are then inserted into the appropriate database table.

Uploaded by

meena jayaraman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

import mysql.

connector as sql
conn = sql.connect(host='localhost', user='root', password='harini0803',
database='Theatre')
c1 = conn.cursor()
if not conn.is_connected():
print('invalid')
else:
print("**********WELCOME TO XII-C THEATRE**********")
print('~~~~~~~~~~ XII-C THEATRE BOOKING (AC & NON AC) ~~~~~~~~~~')
ch = int(input("Enter your choice 1.Ticket Booking 2.Box Office 3.1st Class 4.2nd
Class :"))
if ch == 1:
name = input("Enter the movie name :")
phno = input("Enter phone number :")
tic = int(input("Enter total tickets :"))
gender = input("Enter your gender :")
fname = input("Enter your first name :")
lname = input("Enter your last name :")
passwd = input("Enter your passwd :")
userID = input("Enter your userID :")
snacks = input("Order your snacks :")
price = tic*100
ins = f"insert into ticket_booking
values('{name}','{phno}','{tic}','{gender}','{fname}','{lname}','{passwd}','{userID}','
{snacks}','{price}')"
c1.execute(ins)
conn.commit()
print("******************TICKETS BOOKED******************")
print('******************THANK YOU COME AGAIN*******************')
a = input('Do you want to continue?(yes/no)')
while a=='yes':
ch = int(input("Enter your choice 1.Ticket Booking 2.Box Office 3.1st Class
4.2nd Class :"))
break

if ch==2:
print("******************WELCOME TO XII-C THEATRE*******************")
print("################ WELCOME TO THE BOX OFFICE (AC)##################")
name = input("Enter the movie name :")
phno = input("Enter phone number :")
tic = int(input("Enter total tickets :"))
gender = input("Enter your gender :")
fname = input("Enter your first name :")
lname = input("Enter your last name :")
passwd = input("Enter your passwd :")
userID = input("Enter your userID :")
snacks = input("Order your snacks :")
price = tic * 500
ins = f"insert into box_office
values('{name}','{phno}','{tic}','{gender}','{fname}','{lname}','{passwd}','{userID}','
{snacks}','{price}')"
c1.execute(ins)
conn.commit()
print("*********************TICKETS BOOKED***********************")
print('******************THANK YOU COME AGAIN*******************')
a = input('Do you want to continue?(yes/no)')
while a == 'yes':
ch = int(input("Enter your choice 1.Ticket Booking 2.Box Office 3.1st Class
4.2nd Class :"))
break

if ch==3:
print("************welcome to 1st class ticket booking **************")
name = input("Enter the movie name :")
phno = input("Enter phone number :")
tic = int(input("Enter total tickets :"))
gender = input("Enter your gender :")
fname = input("Enter your first name :")
lname = input("Enter your last name :")
passwd = input("Enter your passwd :")
userID = input("Enter your userID :")
snacks = input("Order your snacks :")
price = tic * 300
ins = f"insert into 1st_class
values('{name}','{phno}','{tic}','{gender}','{fname}','{lname}','{passwd}','{userID}','
{snacks}','{price}')"
c1.execute(ins)
conn.commit()
print("*********************TICKETS BOOKED***********************")
print('******************THANK YOU COME AGAIN*******************')
a = input('Do you want to continue?(yes/no)')
while a == 'yes':
ch = int(input("Enter your choice 1.Ticket Booking 2.Box Office 3.1st Class
4.2nd Class :"))
break

if ch == 4:
print("*************WELCOME TO XII-C THEATRE*************")
print ("!!!!!!!!!!!!WELCOME TO 2nd CLASS TICKET BOOKING !!!!!!!!!!!!!!")
name = input("Enter the movie name :")
phno = input("Enter phone number :")
tic = int(input("Enter total tickets :"))
gender = input("Enter your gender :")
fname = input("Enter your first name :")
lname = input("Enter your last name :")
passwd = input("Enter your passwd :")
userID = input("Enter your userID :")
snacks = input("Order your snacks :")
price = tic * 200
ins = f"insert into 2nd_class values(
'{name}','{phno}','{tic}','{gender}','{fname}','{lname}','{passwd}','{userID}','{snacks
}','{price}')"
c1.execute(ins)
conn.commit()
print("*********************TICKETS BOOKED***********************")
print('******************THANK YOU COME AGAIN*******************')
a = input('Do you want to continue?(yes/no)')
while a == 'yes':
ch = int(input("Enter your choice 1.Ticket Booking 2.Box Office 3.1st Class
4.2nd Class :"))
break

OUTPUT
C:\Users\Admin\PycharmProjects\pythonProject\venv\Scripts\python.exe
C:\Users\Admin\PycharmProjects\pythonProject\main.py
**********WELCOME TO XII-C THEATRE**********
~~~~~~~~~~ XII-C THEATRE BOOKING (AC & NON AC) ~~~~~~~~~~
Enter your choice 1.Ticket Booking 2.Box Office 3.1st Class 4.2nd Class :1
Enter the movie name :bigil
Enter phone number :9710310742
Enter total tickets :5
Enter your gender :male
Enter your first name :arun
Enter your last name :manick
Enter your passwd :am45
Enter your userID :manickarun
Order your snacks :puff
******************TICKETS BOOKED******************
******************THANK YOU COME AGAIN*******************
Do you want to continue?(yes/no)yes
Enter your choice 1.Ticket Booking 2.Box Office 3.1st Class 4.2nd Class :2
******************WELCOME TO XII-C THEATRE*******************
################ WELCOME TO THE BOX OFFICE (AC)##################
Enter the movie name :varisu
Enter phone number :9654323914
Enter total tickets :5
Enter your gender :female
Enter your first name :priya
Enter your last name :ram
Enter your passwd :pr91
Enter your userID :priya5632ram
Order your snacks :coke
*********************TICKETS BOOKED***********************
******************THANK YOU COME AGAIN*******************
Do you want to continue?(yes/no)yes
Enter your choice 1.Ticket Booking 2.Box Office 3.1st Class 4.2nd Class :3
************welcome to 1st class ticket booking **************
Enter the movie name :thuppaki
Enter phone number :9136457134
Enter total tickets :2
Enter your gender :female
Enter your first name :likitha
Enter your last name :sankar
Enter your passwd :lis5
Enter your userID :likisankar9135
Order your snacks :cake
*********************TICKETS BOOKED***********************
******************THANK YOU COME AGAIN*******************
Do you want to continue?(yes/no)yes
Enter your choice 1.Ticket Booking 2.Box Office 3.1st Class 4.2nd Class :4
*************WELCOME TO XII-C THEATRE*************
!!!!!!!!!!!!WELCOME TO 2nd CLASS TICKET BOOKING !!!!!!!!!!!!!!
Enter the movie name :beast
Enter phone number :9416340136
Enter total tickets :4
Enter your gender :male
Enter your first name :praveen
Enter your last name :raman
Enter your passwd :pr01
Enter your userID :praveramu4512
Order your snacks :chips
*********************TICKETS BOOKED***********************
******************THANK YOU COME AGAIN*******************
Do you want to continue?(yes/no)no

Process finished with exit code 0


Result
mysql> use theatre;
Database changed
mysql> show tables;
+-------------------+
| Tables_in_theatre |
+-------------------+
| 1st_class |
| 2nd_class |
| box_office |
| ticket_booking |
+-------------------+
4 rows in set (0.08 sec)

mysql> select * from 1st_class;


+----------+------------+--------+--------+------------+-----------+----------+----------------+--------+-------+
| Name | phno | Ticket | Gender | First_name | Last_name | Password | UserID | Snacks | Price |
+----------+------------+--------+--------+------------+-----------+----------+----------------+--------+-------+
| thuppaki | 9136457134 | 2 | female | likitha | sankar | lis5 | likisankar9135 | cake | 600 |
+----------+------------+--------+--------+------------+-----------+----------+----------------+--------+-------+
1 row in set (0.00 sec)

mysql> select * from 2nd_class;


+-------+------------+--------+--------+------------+-----------+----------+---------------+--------+-------+
| Name | phno | Ticket | Gender | First_name | Last_name | Password | UserID | Snacks | Price |
+-------+------------+--------+--------+------------+-----------+----------+---------------+--------+-------+
| beast | 9416340136 | 4 | male | praveen | raman | pr01 | praveramu4512 | chips | 800 |
+-------+------------+--------+--------+------------+-----------+----------+---------------+--------+-------+
1 row in set (0.00 sec)
mysql> select * from box_office;
+--------+------------+--------+--------+------------+-----------+----------+--------------+--------+-------+
| Name | phno | Ticket | Gender | First_name | Last_name | Password | UserID | Snacks | Price |
+--------+------------+--------+--------+------------+-----------+----------+--------------+--------+-------+
| varisu | 9654323914 | 5 | female | priya | ram | pr91 | priya5632ram | coke | 2500 |
+--------+------------+--------+--------+------------+-----------+----------+--------------+--------+-------+
1 row in set (0.00 sec)

mysql> select * from ticket_booking;


+-------+------------+--------+--------+------------+-----------+----------+------------+--------+-------+
| Name | phno | Ticket | Gender | First_name | Last_name | Password | UserID | Snacks | price |
+-------+------------+--------+--------+------------+-----------+----------+------------+--------+-------+
| bigil | 9710310742 | 5 | male | arun | manick | am45 | manickarun | puff | 500 |
+-------+------------+--------+--------+------------+-----------+----------+------------+--------+-------+
1 row in set (0.02 sec)

You might also like