-
Notifications
You must be signed in to change notification settings - Fork 0
/
movie.py
27 lines (21 loc) · 1.08 KB
/
movie.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
class movie:
def __init__(self, db_cursor, mydb):
self.db_cursor = db_cursor
self.mydb = mydb
def add_movie(self, movie_title, movie_year, rating_id):
self.db_cursor.execute('INSERT INTO movie (movie_title, movie_year, rating_id) VALUES (%s, %s, %s)',
(movie_title, movie_year, rating_id))
self.mydb.commit()
print(self.db_cursor.rowcount, 'record inserted.')
print('\n')
def update_movie(self, movie_id, new_movie_title, new_movie_year, new_rating_id):
self.db_cursor.execute('UPDATE movie SET movie_title = %s, movie_year = %s, rating_id = %s WHERE movie_id = %s',
(new_movie_title, new_movie_year, new_rating_id, movie_id))
self.mydb.commit()
print(self.db_cursor.rowcount, 'record updated.')
print('\n')
def delete_movie(self, movie_id):
self.db_cursor.execute('DELETE FROM movie WHERE movie_id = %s', (movie_id, ))
self.mydb.commit()
print(self.db_cursor.rowcount, 'record deleted.')
print('\n')