-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchange_main.py
350 lines (287 loc) · 15.6 KB
/
change_main.py
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
import os
import pymysql
print("----------------------------------------------------------------")
print("")
print(" DataBase FinalProject _ 201811299 최범준 ")
print("")
print("----------------------------------------------------------------")
print("")
returnNum = 0
def open_db():
conn = pymysql.connect(host="localhost", user="root", password="1019", db="final", charset="utf8")
curs = conn.cursor(pymysql.cursors.DictCursor)
return conn, curs
def cls():
os.system('cls' if os.name == 'nt' else 'clear')
# now, to clear the screen : cls()
def orderBY():
print(" 1. Year-to-year sorting(ORDERBY) \n 2. Open Date Sorting(ORDERBY) \n 3. alphabetical order(ORDERBY)")
print("")
print("----------------------------------------------------------------")
getnum = input()
while(getnum != "1" and getnum != "2" and getnum != "3"):
getnum = input()
print("Enter again!")
return getnum
def console():
conn, cur = open_db()
while True:
# acls()
print(" a. Search movie information \n b. Search an actor's film \n c. Search a director's film \n d. Search movies with genre \n e. Search movies with opening date \n f. Search the actor in the movie \n g. Search the director who produced the movie \n h. Search the famous lines of the movie \n i. search the review of the movie \n q. exit")
print("")
print("----------------------------------------------------------------")
temp = input()
# 종료
if temp == "q":
cur.close()
conn.close()
break
# 영화 제목 검색
elif temp == "a":
print("----------------------------------------------------------------")
print("\n")
returnNUM = orderBY()
print(returnNUM)
returnNUM = int(float(returnNUM))
print("----------------------------------------------------------------\n")
sql = ""
title = input("Enter the movie title : ")
if returnNUM == 1:
sql = """select distinct *
from movie m
where m.title = '%s' order by m.enter_date;""" % (title)
if returnNUM == 2:
sql = """select distinct * from m.title = '%s' order by m.opening_date;""" % (title)
if returnNUM == 3:
sql = """select distinct * from m.title = '%s' order by m.title;""" % (title)
cur.execute(sql)
r = cur.fetchone()
while r:
print('movie code : %s, movie title(kor) : %s, movie title(eng) : %s, netizen rate : %s, audience rate : %s, review count : %s, running time : %s, Opening date: %s, image link : %s ' % (r['code_movie'], r['title'], r['title_English'], r['netizen_rate'], r['audience_rate'], r['review_count'], r['playing_time'], r['opening_date'], r['image']))
r = cur.fetchone()
print("----------------------------------------------------------------")
print("\n")
# 배우가 출연한 영화 검색
elif temp == "b":
print("----------------------------------------------------------------\n")
returnNUM = orderBY()
print(returnNUM)
returnNUM = int(float(returnNUM))
print("----------------------------------------------------------------\n")
sql = ""
actor = input("Enter the actor name. : ")
if returnNUM == 1:
sql = """select distinct * from movie m, actor a where m.code_movie=a.code_movie and a.actor_name = '%s' group by m.code_movie order by m.enter_date;""" % (actor)
if returnNUM == 2:
sql = """select distinct * from movie m, actor a where m.code_movie=a.code_movie and a.actor_name = '%s' group by m.code_movie order by m.opening_date;""" % (actor)
if returnNUM == 3:
sql = """select distinct * from movie m, actor a where m.code_movie=a.code_movie and a.actor_name = '%s' group by m.code_movie order by m.title;""" % (actor)
cur.execute(sql)
r = cur.fetchone()
while r:
print('actor code : %s, movie code : %s, movie title(kor) : %s, name : %s, role : %s, casting name : %s ' % (
r['actor_code'], r['code_movie'], r['title'], r['actor_name'], r['role'], r['casting_name']))
r = cur.fetchone()
print("----------------------------------------------------------------")
print("\n")
# 감독이 제작한 영화 검색
elif temp == "c":
print("----------------------------------------------------------------\n")
returnNUM = orderBY()
print(returnNUM)
returnNUM = int(float(returnNUM))
print("----------------------------------------------------------------\n")
sql = ""
director = input("Enter the director name. : ")
if returnNUM == 1:
sql = """select distinct * from movie m, director d where m.code_movie=d.code_movie and d.name_korean = '%s' group by m.code_movie order by m.enter_date;""" % (
director)
if returnNUM == 2:
sql = """select distinct * from movie m, director d where m.code_movie=d.code_movie and d.name_korean = '%s' group by m.code_movie order by m.opening_date;""" % (
director)
if returnNUM == 3:
sql = """select distinct * from movie m, director d where m.code_movie=d.code_movie and d.name_korean = '%s' group by m.code_movie order by m.title;""" % (
director)
cur.execute(sql)
r = cur.fetchone()
while r:
print('director code : %s, movie code : %s, title : %s , name(kor) : %s, name(eng) : %s, Filmography : %s ' % (
r['director_code'], r['code_movie'], r['title'], r['name_korean'], r['name_English'], r['work_name']))
r = cur.fetchone()
print("----------------------------------------------------------------")
print("\n")
# 장르 검색
elif temp == "d":
print("----------------------------------------------------------------\n")
returnNUM = orderBY()
print(returnNUM)
print("----------------------------------------------------------------\n")
returnNUM = int(float(returnNUM))
sql = ""
genre = input("Enter the Genre : ")
if returnNUM == 1:
sql = """select distinct * from movie m, genre g where m.code_movie=g.code_movie and g.genre = '%s' group by m.code_movie order by m.enter_date;""" % (
genre)
if returnNUM == 2:
sql = """select distinct * from movie m, genre g where m.code_movie=g.code_movie and g.genre = '%s' group by m.code_movie order by m.opening_date;""" % (
genre)
if returnNUM == 3:
sql = """select distinct * from movie m, genre g where m.code_movie=g.code_movie and g.genre = '%s' group by m.code_movie order by m.title;""" % (
genre)
cur.execute(sql)
r = cur.fetchone()
while r:
print('code_movie : %s, title : %s , genre : %s ' % (
r['code_movie'], r['title'], r['genre']))
r = cur.fetchone()
print("----------------------------------------------------------------")
print("\n")
# 개봉 연도를 기준으로 검색
elif temp == "e":
print("----------------------------------------------------------------\n")
returnNUM = orderBY()
print(returnNUM)
print("----------------------------------------------------------------\n")
returnNUM = int(float(returnNUM))
sql = ""
openining_date = input("Enter the opening date : ")
if returnNUM == 1:
sql = """select distinct * from movie m where year(m.opening_date) = '%s' group by m.code_movie order by m.enter_date;""" % (
openining_date)
if returnNUM == 2:
sql = """select distinct * from movie m where year(m.opening_date) = '%s' group by m.code_movie order by m.opening_date;""" % (
openining_date)
if returnNUM == 3:
sql = """select distinct * from movie m where year(m.opening_date) = '%s' group by m.code_movie order by m.title;""" % (
openining_date)
cur.execute(sql)
r = cur.fetchone()
while r:
print('code_movie : %s, title : %s , opening_date : %s ' % (
r['code_movie'], r['title'], r['opening_date']))
r = cur.fetchone()
print("----------------------------------------------------------------")
print("\n")
elif temp == "g":
print("----------------------------------------------------------------\n")
returnNUM = orderBY()
print(returnNUM)
print("----------------------------------------------------------------\n")
returnNUM = int(float(returnNUM))
sql = ""
tmp = input("Enter the title : ")
if returnNUM == 1:
sql = """select distinct *
from movie m, director d
where m.code_movie = d.code_movie and m.title = '%s'
order by m.enter_date;""" % (tmp)
if returnNUM == 2:
sql = """select distinct *
from movie m, director d
where m.code_movie = d.code_movie and m.title = '%s'
order by m.opening_date;""" % (tmp)
if returnNUM == 3:
sql = """select distinct *
from movie m, director d
where m.code_movie = d.code_movie and m.title = '%s'
order by m.title;""" % (tmp)
cur.execute(sql)
r = cur.fetchone()
while r:
print('code_movie : %s, title : %s ,irector_code : %s, name_korean : %s ' % (
r['code_movie'], r['title'], r['director_code'], r['name_korean']))
r = cur.fetchone()
print("----------------------------------------------------------------")
print("\n")
elif temp == "f":
print("----------------------------------------------------------------\n")
returnNUM = orderBY()
print(returnNUM)
print("----------------------------------------------------------------\n")
returnNUM = int(float(returnNUM))
sql = ""
tmp = input("Enter the title : ")
if returnNUM == 1:
sql = """select distinct *
from movie m, actor a
where m.code_movie = a.code_movie and m.title = '%s'
order by m.enter_date;""" % (tmp)
if returnNUM == 2:
sql = """select distinct *
from movie m, actor a
where m.code_movie = a.code_movie and m.title = '%s'
order by m.opening_date;""" % (tmp)
if returnNUM == 3:
sql = """select distinct *
from movie m, actor a
where m.code_movie = a.code_movie and m.title = '%s'
order by m.title;""" % (tmp)
cur.execute(sql)
r = cur.fetchone()
while r:
print('code_movie : %s, itle : %s , actor_name : %s, role : %s, casting_name : %s' % (
r['code_movie'], r['title'], r['actor_name'], r['role'], r['casting_name']))
r = cur.fetchone()
print("----------------------------------------------------------------")
print("\n")
# 명대사 검색
elif temp == "h":
print("----------------------------------------------------------------\n")
returnNUM = orderBY()
print(returnNUM)
print("----------------------------------------------------------------\n")
returnNUM = int(float(returnNUM))
sql = ""
famous_line = input("Enter the title : ")
if returnNUM == 1:
sql = """select * from movie m, famous_lines f where m.code_movie = f.code_movie and m.title = '%s' order by m.enter_date;""" % (
famous_line)
if returnNUM == 2:
sql = """select * from movie m, famous_lines f where m.code_movie = f.code_movie and m.title = '%s' order by m.opening_date;""" % (
famous_line)
if returnNUM == 3:
sql = """select * from movie m, famous_lines f where m.code_movie = f.code_movie and m.title = '%s' order by m.title;""" % (
famous_line)
cur.execute(sql)
r = cur.fetchone()
while r:
print('code_movie : %s, title : %s , famous_line : %s' % (
r['code_movie'], r['title'], r['famous_line']))
r = cur.fetchone()
print("----------------------------------------------------------------")
print("\n")
elif temp == "i":
print("----------------------------------------------------------------\n")
returnNUM = orderBY()
print(returnNUM)
print("----------------------------------------------------------------\n")
returnNUM = int(float(returnNUM))
sql = ""
title = input("Enter the title : ")
if returnNUM == 1:
sql = """select *
from movie m, review r
where m.code_movie = r.code_movie and m.title = '%s' order by m.enter_date;""" % (title)
if returnNUM == 2:
sql = """select *
from movie m, review r
where m.code_movie = r.code_movie and m.title = '%s' order by m.opening_date;""" % (
title)
if returnNUM == 3:
sql = """select *
from movie m, review r
where m.code_movie = r.code_movie and m.title = '%s' order by m.title;""" % (title)
cur.execute(sql)
r = cur.fetchone()
while r:
print(
'code_movie : %s, title : %s , review_title : %s , review_text : %s , review_uname : %s , review_date : %s eview_good : %s' % (
r['code_movie'], r['title'], r['review_title'], r['review_text'], r['review_uname'],
r['review_date'], r['review_good']))
r = cur.fetchone()
print("----------------------------------------------------------------")
print("\n")
else:
print("Enter again!")
if __name__ == '__main__':
console()