CS_project_2024_25_kanishka_selvy
CS_project_2024_25_kanishka_selvy
SCHOOL
Group members :
Submitted by:
Kanishka Kolte
SELVY
Selvy Kushwaha KUSHWAHA
Class: 12th Sci.CBSE B
INDEX
SOFTWARE REQUIREMENTS:
HARDWARE REQUIREMENTS:
1.Creating Table(file1)
import mysql.connector
import random as r
mydb = mysql.connector.connect(host='localhost', user='root',
password='1234')
mycursor=mydb.cursor()
mycursor.execute("show databases")
for r in mycursor:
print(r)
mycursor.execute("CREATE database Moviebookingsystem")
mycursor.execute("USE moviebookingsystem")
#creating tables
mycursor.execute("""
CREATE TABLE Movie_listings (
mv_id INT PRIMARY KEY,
movie_name VARCHAR(75) NOT NULL,
plot VARCHAR(500),
cast VARCHAR(500)
)
""")
mycursor.execute("""
CREATE TABLE showtimes (
show_time_id INT PRIMARY KEY,
mv_id INT,
movie_name VARCHAR(75),
show_date DATE,
show_time VARCHAR(15),
tickets INT,
Cinema CHAR(30),
FOREIGN KEY (mv_id) REFERENCES Movie_listings(mv_id)
)
""")
mycursor.execute("""
CREATE TABLE bookings (
booking_id INT PRIMARY KEY,
show_time_id INT,
name VARCHAR(75),
phone_number VARCHAR(10),
cost INT,
FOREIGN KEY (show_time_id) REFERENCES
showtimes(show_time_id)
)
""")
2.Adding data into movie_listings and showtimes(file2)
import mysql.connector
import random as r
mydb = mysql.connector.connect(host='localhost', user='root',
password='1234')
mycursor=mydb.cursor()
mycursor.execute("Use moviebookingsystem")
"""# Data to insert
data = [
(1, "Bhool Bhulaiya 3", "In Kolkata, Rooh Baba enters a spooky
estate where he confronts a pair of vindictive ghosts, both asserting
to be Manjulika..", "Vidya Balan, Madhuri Dixit"),
(2, "Insider Out 2", "Joy, Sadness, Anger, Fear and Disgust have
been running a successful operation by all accounts. However, when
Anxiety shows up, they aren't sure how to feel", "Mindy Kaling, Maya
Hawke"),
(3, "Kalki-2898 AD", "A modern avatar of the Hindu god Vishnu, is
said to have descended on Earth to protect the world from evil
forces.", "Amitabh Bacchan,Prabhas"),
(4, "Avatar", "A paraplegic marine on an alien planet fights for its
survival.", "Sam Worthington, Zoe Saldana"),
(5, "Crew", "Hailed as `delectable' by The Times of India, this
Rajesh Krishnan-directed comedy follows three bold flight attendants
caught in a gold smuggling ring.", "Kareena Kapoor,Tabu")
]
mycursor.execute("USE moviebookingsystem")
mycursor.execute("SELECT * FROM Showtimes")
rows = mycursor.fetchall()
columns = [i[0] for i in mycursor.description]
print(" | ".join(columns))
while True:
print("""1.show details of movie
2.Filter by cinema
3.Booking of movie
4.stop""")
var=int(input("Enter choice 1/2/3/4"))
if var==1:
mv=int(input("Enter movie id"))
query="""SELECT movie_name,plot,cast
FROM movie_listings
Where mv_id=%s"""
mycursor.execute(query,(mv,))
result=mycursor.fetchone()
if result:
print(f"movie name: {result[0]}")
print(f"Plot: {result[1]}")
print(f"Cast: {result[2]}")
else:
print("no movie found!")
elif var==2:
ch=input("enter desired cinema name")
var2="""SELECT *
FROM Showtimes
WHERE Cinema =%s"""
mycursor.execute(var2,(ch,))
res=mycursor.fetchall()
if res:
columns = [i[0] for i in mycursor.description]
print(" | ".join(columns))
elif var==3:
u=0
s_id=int(input("Enter showtime id"))
while True:
u=u+1
query1="SELECT * from showtimes where show_time_id=%s"
mycursor.execute(query1,(s_id,))
result1=mycursor.fetchone()
id1=int(result1[5])
l=r.randrange(1,10000000)
n=input("enter your name")
mb=int(input("enter your mobile number"))
ql="""INSERT INTO bookings
(booking_id,show_time_id,name,phone_number,cost)
Values(%s,%s,%s,%s,%s)"""
val=(l,s_id,n,mb,id1)
mycursor.execute(ql,val)
mydb.commit()
ch=input("do you want to continue(y/n)")
if ch=='n':
break
print("record inserted")
elif ch=='y':
pass
else:
print("invalid input")
print(u,"records inserted")
mycursor.execute("SELECT * FROM bookings")
result = mycursor.fetchall()
clmn= ['booking_id', 'showtime_id', 'name', 'phone number',
'ticket']
print("\t".join(clmn))
for row in result:
print("\t".join(str(item) for item in row))
elif var==4:
break
else:
print("invalid input")
mycursor.close()
mydb.close()