You are on page 1of 8

import mysql.

connector
import pandas as pd
from tabulate import tabulate
con = mysql.connector.connect(host="localhost", user="root", passwd="05111721",
database="movie")
cr = con.cursor()
def movie_search():
try:
x = int(input('Enter movie code: '))
qry = "SELECT * FROM movies WHERE movie_code=%s"
cr.execute(qry, (x,))
r = cr.fetchone()
if r:
df = pd.read_sql_query(qry, con, params=(x,))
print(tabulate(df, headers="keys", tablefmt='psql', showindex=False))
else:
print('Wrong movie id')
except:
print("enter data correctly")
def add_movies():
try:
movie_code=input()
movie_name=input()
budget= int(input())
collection= int(input())
target=int(input())
qry= "insert into movies values('{}','{}',{},{},{});".format(movie_code,
movie_name,budget,collection,target)
cr.execute(qry)
con.commit()
except:
print('enter data correctly')
#writer
def add_writer():
try:
emp_id=int(input('employee id'))
emp_name=input('empname')
designation=input('designation')
salary=int(input('salary'))
qry="insert into employee values({},'{}','{}','{}',
{});".format(emp_id,emp_name,'writing',designation,salary)
cr.execute(qry)
con.commit()
except:
print('enter data correctly')
def writer_search():
try:
x = int(input('Enter emp_id: '))
qry = "SELECT * FROM employee WHERE emp_id=%s and department='writing';"
cr.execute(qry, (x,))
r = cr.fetchone()
if r:
df = pd.read_sql_query(qry, con, params=(x,))
print(tabulate(df, headers="keys", tablefmt='psql', showindex=False))
else:
print('id does not exist')
except:
print('enter id in correct formate')
def increment_w():
try:
x = int(input("Enter Employee ID: "))
qry = "select * from employee where empid={} and
department='writing';".format(x)
cr.execute(qry)
r = cr.fetchone()
if r:
y = int(input("Enter new salary: "))
qry = "Update employee Set Salary={} where emp_id={}".format(y, x)
con.commit()
print("Edited Successfully")
else:
print("Wrong")
except:
print('enter amount correctly')
def delete_writer():
try:
x = int(input("Enter Employee ID: ")) # Added a missing closing parenthesis
qry = "SELECT * FROM employee WHERE emp_id = {} and department
='Writing';".format(x) # Fixed the SQL query
cr.execute(qry)
r = cr.fetchone()
if r:
qry = "DELETE FROM employee WHERE emp_id = {}".format(x) # Fixed the
DELETE query
cr.execute(qry)
con.commit()
print("Deleted Successfully")
else:
print("Employee not found")
except:
print('enter id properly') #sound
def add_voice_artist():
try:
emp_id=int(input('emp id'))
emp_name=input('empname')
designation=input('designation')
salary=int(input('salary'))
qry="insert into employee values({},'{}','{}','{}',
{});".format(emp_id,emp_name,'sound',designation,salary)
cr.execute(qry)
con.commit()
except:
print('enter data properly')
def voice_artist_search():
try:
x = int(input('Enter emp_id: '))
qry = "SELECT * FROM employee WHERE emp_id=%s and department='sound';"
cr.execute(qry, (x,))
r = cr.fetchone()
if r:
df = pd.read_sql_query(qry, con, params=(x,))
print(tabulate(df, headers="keys", tablefmt='psql', showindex=False))
else:
print('id does not exist')
except:
print('enter id properly')
def increment_v():
try:
x = int(input("Enter Employee ID: "))
qry = "select * from employee where empid={} and
department='sound';".format(x)
cr.execute(qry)
r = cr.fetchone()
if r:
y = int(input("Enter new salary: "))
qry = "Update employee Set Salary={} where emp_id={}".format(y, x)
con.commit()
print("Edited Successfully")
else:
print("Wrong")
except:
print('enter amount properly')
def delete_voice_artist():
try:
x = int(input("Enter Employee ID: ")) # Added a missing closing parenthesis
qry = "SELECT * FROM employee WHERE emp_id = {} and department
='sound';".format(x) # Fixed the SQL query
cr.execute(qry)
r = cr.fetchone()
if r:
qry = "DELETE FROM employee WHERE emp_id = {}".format(x) # Fixed the
DELETEquery
cr.execute(qry)
con.commit()
print("Deleted Successfully")
else:
print("Employee not found")
except:
print('enter id properly')
#animation
def add_animator():
try:
emp_id=int(input("enter employee id"))
emp_name=input("enter employee name")
designation=input('designation')
salary=int(input('salary'))
qry="insert into employee values({},'{}','{}','{}',
{});".format(emp_id,emp_name,'animation',designation,salary)
cr.execute(qry)
con.commit()
except:
print("enter data properly")
def animator_search():
try:
x = int(input('Enter emp_id: '))
qry = "SELECT * FROM employee WHERE emp_id=%s and department='animation';"
cr.execute(qry, (x,))
r = cr.fetchone()
if r:
df = pd.read_sql_query(qry, con, params=(x,))
print(tabulate(df, headers="keys", tablefmt='psql', showindex=False))
else:
print('id does not exist')
except:
print("enter data properly")
def increment_a():
try:
x = int(input("Enter Employee ID: "))
qry = "select * from employee where empid={} and
department='animation';".format(x)
cr.execute(qry)
r = cr.fetchone()
if r:
y = int(input("Enter new salary: "))
qry = "Update employee Set Salary={} where emp_id={}".format(y, x)
con.commit()
print("Edited Successfully")
else:
print("Wrong")
except:
print("enter data properly")
def delete_animator():
try:
x = int(input("Enter Employee ID: ")) # Added a missing closing parenthesis
qry = "SELECT * FROM employee WHERE emp_id = {} and department
='animation';".format(x) # Fixed the SQL query
cr.execute(qry)
r = cr.fetchone()
if r:
qry = "DELETE FROM employee WHERE emp_id = {}".format(x) # Fixed the
DELETE query
cr.execute(qry)
con.commit()
print("Deleted Successfully")
else:
print("Employee not found")
except:
print("enter data properly")
#supervisor
def add_supervisor():
try:
emp_id=int(input('enter employee id'))
emp_name=input('employee name')
designation=input('designation')
salary=int(input('salary'))
qry="insert into employee values({},'{}','{}','{}',
{});".format(emp_id,emp_name,'supervise',designation,salary)
cr.execute(qry)
con.commit()
except:
print('enter data properly')
def supervisor_search():
try:
x = int(input('Enter emp_id: '))
qry = "SELECT * FROM employee WHERE emp_id=%s and department='supervise';"
cr.execute(qry, (x,))
r = cr.fetchone()
if r:
df = pd.read_sql_query(qry, con, params=(x,))
print(tabulate(df, headers="keys", tablefmt='psql', showindex=False))
else:
print('id does not exist')
except:
print('enter data properly')
def increment_s():
try:
x = int(input("Enter Employee ID: "))
qry = "select * from employee where empid={} and
department='supervise';".format(x)
cr.execute(qry)
r = cr.fetchone()
if r:
y = int(input("Enter new salary: "))
qry = "Update employee Set Salary={} where emp_id={}".format(y, x)
con.commit()
print("Edited Successfully")
else:
print("Wrong")
except:
print("enter data properly")
def delete_supervisor():
try:
x = int(input("Enter Employee ID: ")) # Added a missing closing parenthesis
qry = "SELECT * FROM employee WHERE emp_id = {} and department
='supervise';".format(x) # Fixed the SQL query
cr.execute(qry)
r = cr.fetchone()
if r:
qry = "DELETE FROM employee WHERE emp_id = {}".format(x) # Fixed the
DELETE query
cr.execute(qry)
con.commit()
print("Deleted Successfully")
else:
print("Employee not found")
except:
print("enter data correctly")
def signup():
username = input("Enter your username: ")
password = getpass("Enter your password: ")
# Inserting user data into the table
sql = "INSERT INTO users (username, password) VALUES (%s, %s)"
val = (username, password)
mycursor.execute(sql, val)
mydb.commit()
print("Signup successful!")
while True:
print("ENTER YOUR CHOICE \n 1. signup \n 2. Login \n 3. exit")
ch=int(input("enter your choice"))
if ch==1:
signup()
elif ch==2:
username = input("Enter your username: ")
password = getpass("Enter your password: ")
sql = "SELECT * FROM users WHERE username = %s AND password = %s"
val = (username, password)
mycursor.execute(sql, val)
myresult = mycursor.fetchall()
if myresult:
print("Login successful!")
while True:
print('enter your choice \n 1. Movies \n 2. Employee \n 3.
Statistics \n 4. Finance \n 5.Sign Out \n:-')
a = int(input())
if a == 1:
while True:
print('ENTER YOUR CHOICE \n 1. To view movies detail \n
2. To add movie etail \n 3. Back to main menu:')
b = int(input())
if b == 1:
movie_search()
elif b == 2:
add_movies()
elif b == 3:
break
elif a == 2:
while True:
print('CHOOSE DEPARTMENT \n 1. Writing Department \n 2.
Sound Department\n 3. Animation Department \n 4. Supervisor Department \n 5. Back
to Main Menu')
c = int(input())
if c == 1:
while True:
print('ENTER YOUR CHOICE \n 1. to add employee
data\n 2. to view mployee details \n 3. to modify salary of employee \n 4. to
remove employee \n 5. back to main enu')
u = int(input())
if u == 1:
add_writer()
elif u == 2:
writer_search()
elif u == 3:
increament_w()
elif u == 4:
delete_writer()
elif u == 5:
break
elif c == 2:
while True:
print('ENTER YOUR CHOICE \n 1. to add employee
data\n 2. to viewemployee details \n 3. to modify salary of employee \n 4. to
remove employee \n 5. back to main enu')
v = int(input())
if v == 1:
add_voice_artist()
elif v == 2:
voice_artist_search()
elif v == 3:
increament_v()
elif v == 4:
delete_voice_artist()
elif v == 5:
break
elif c == 3:
while True:
print('ENTER YOUR CHOICE \n 1. to add employee
data\n 2. to view employee details \n 3. to modify salary of employee \n 4. to
remove employee \n 5. back to main menu')
w= int(input())
if w == 1:
add_animator()
elif w== 2:
animator_search()
elif w == 3:
increament_a()
elif w== 4:
delete_animator()
elif w == 5:
break
elif c == 4:
while True:
print('ENTER YOUR CHOICE \n 1. to add employee
data\n 2. to view employee details \n 3. to modify salary of employee \n 4. to
remove employee \n 5. back to main menu')
x = int(input())
if x == 1:
add_supervisor()
elif x== 2:
supervisor_search()
elif x == 3:
increament_s()
elif x == 4:
delete_supervisor()
elif x == 5:
break
elif c == 5:
break
elif a == 3:
x_values =
[2011,2012,2013,2014,2015,2016,2017,2018,2019,2020]
y_values = [13.4,18,17,21,22.8,28,31,12,7,29.3]
# Plotting the graph
plt.plot(x_values, y_values)
# Adding a title and labels
plt.title('INTERACTIONS PAST 10 YEAR')
plt.xlabel('YEAR')
plt.ylabel('VIEWS IN MILLION')
# Display the graph
plt.show()
elif a == 4:
while True:
print('enter data chart you wanna see \n 1. studio
finnance stats over 10 year \n 2.movies collection and there budgets \n 3. back to
ain menu')
d = int(input())
if d == 1:
# Data for the first chart
x1 = [200,250,277,421,423,450,230,455,66,630]
y1 =
[2011,2012,2013,2014,2015,2016,2017,2018,2019,2020]
x2 = [150,190,100,200,78,400,160,200,130,660]
fig, ax = plt.subplots()
# Plotting the first chart
ax.plot(y1,x1, label='COLLECTION PAST 10 YEAR',
color='b')
# Plotting the second chart
ax.plot( y1,x2, label='BUDGET PAST 10 YEAR',
color='r', linestyle='--')
# Adding a legend
ax.legend()
plt.ylabel('amount in crore')
# Display the plot
plt.show()
elif d == 2:
cr.execute("select movie_name,collection from
movies")
result = cr.fetchall()
Names = []
collection = []
for i in cr:
Names.append(i[0])
collectiom.append(i[1])
print("Name of movie= ", Names)
print("COLLECTION = ", collection)
# Visualizing Data using Matplotlib
plt.bar(Names, collectiom)
plt.ylim(0, 5)
plt.xlabel("Name of MOVIE")
plt.ylabel("Boxoffice collectiom")
plt.title("MOVIE COLLECTION")
plt.show()
elif d == 3:
break
elif a == 5:
break
else:
print("Login failed. Please check your username and
password.")
else:
print("thanks for visiting")
break

You might also like