-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathourWatchlist.py
More file actions
132 lines (94 loc) · 3.97 KB
/
Copy pathourWatchlist.py
File metadata and controls
132 lines (94 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import sqlite3
conn = sqlite3.connect('Watchlist.db')
c = conn.cursor()
# c.execute("""CREATE TABLE Watchlist (
# dramaName text,
# Genre text,
# priorityNum integer
# ) """)
class User:
def __init__(self,name,age):
self.userName=name
self.userAge=age
#INSERTION ACCORDING TO USER INPUT
def insertion(self):
ans = ('yes')
while True:
print("\nDo you want to add dramas into your watchlist ? (Type in yes or no)")
ans = input('-> ')
if (ans.lower() == 'yes'):
name = input('\nName: ')
genreName = input('Genre: ')
priority= int(input('Priority(1-10, lowest-highest): '))
c.execute("""
INSERT INTO Watchlist(dramaName,Genre,priorityNum)
VALUES (?,?,?)
""", (name, genreName, priority))
conn.commit ()
print ( '\nYOUR DATA HAS BEEN ENTERED SUCCESSFULLY :)' )
else:
break
print('INSERTION HAS FINISHED!!')
#SEARCHING ACCORDING TO GENRE OF DRAMA
def search(self):
searchBase = input("\nEnter a Genre of the drama you want to watch: ")
selection = ''' SELECT * from Watchlist where Genre like '%{}%' '''.format(searchBase)
result = c.execute(selection)
condition = False
for data in result:
condition = True
print(f"\nDrama Name: {data[0]}")
print(f"Priority: {data[2]}")
print('------------------*------------------')
conn.commit()
if condition == False:
print(':( OOPS!! THE DRAMA YOU SEARCHED IS NOT IN YOUR WATCHLIST.')
#DELETION ACCORDING TO NAME OF DRAMA
def delete(self):
delBase = input("\nEnter the Drama Name you want to delete: ")
sel = ''' SELECT * from Watchlist where dramaName like '%{}%' '''.format(delBase)
result = c.execute(sel)
for data in result:
delSel = ''' DELETE from Watchlist where dramaName like '%{}%' '''.format(delBase)
c.execute(delSel)
print(f"{data[0]} deleted succesfully!!")
conn.commit()
return
print(':( OOPS!! THE DRAMA YOU WANT TO DELETE IS NOT IN YOUR WATCHLIST')
#selection
def select(self):
choice = 1 or 2 or 3
while True:
print("\n**************************************************************")
print("* Select 1 to Insert the Drama Name in your Watchlist. *")
print("* Select 2 to Search Drama from your Watchlist. *")
print("* Select 3 to Delete the watched Drama from your Watchlist. *")
print("* Select 4 to exit. *")
print("**************************************************************\n")
choice = int(input('YOUR SELECTED NUMBER: '))
match (choice):
case 1:
user1.insertion()
case 2:
user1.search()
case 3:
user1.delete()
case 4:
break
case _:
print("\nPlease, select the correct option.")
# driver code
print("\n*******************************")
print("** DRAMA WATCHLIST **")
print("*******************************")
print("\nHi,")
name=input('\nEnter your Name: ')
try:
age=int(input('Enter your Age: '))
if age<12:
raise ValueError("\nSORRY (T_T) YOU ARE NOT ELIGIBLE FOR WATCHING DRAMAS.\n")
except ValueError as ve:
print(ve)
exit()
user1=User(name,age)
user1.select()