-
Notifications
You must be signed in to change notification settings - Fork 0
/
reservations.py
76 lines (61 loc) · 1.81 KB
/
reservations.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
from movies import Movies
from projections import Projections
# from available_seats import AvailableSeats
class Reservations:
INSERT_USERNAME = """
INSERT INTO Reservations(username)
VALUES(?)
"""
SEARCH_FOR_USERNAME = """
SELECT username
FROM Reservations
"""
CHOOSE_MOVIE_NAME = """
SELECT name
FROM Movies
WHERE id = ?
"""
AVAILABLE_SEATS = """
SELECT available_seats
FROM Projections
"""
UPDATE_ROW_AND_COLUMN = """
UPDATE Reservations
SET row = ?, col = ?
WHERE id = ?
"""
SELECT_ROW_AND_COLUMN = """
SELECT id
FROM Reservations
WHERE username = ? AND row=-1 AND col=-1
"""
SELECT_ROW_AND_COLUMN_BY_ID = """
SELECT row, col
FROM Reservations
WHERE id = ?
"""
@classmethod
def make_reservation(cls, conn, username):
cursor = conn.cursor()
cursor.execute(cls.INSERT_USERNAME, (username,))
Movies.show_current_movies(conn)
conn.commit()
@classmethod
def search_for_user(cls, conn, username):
cursor = conn.cursor()
cursor.execute(cls.SEARCH_FOR_USERNAME)
conn.commit()
@classmethod
def choose_movie(cls, conn, movie_id):
res = Projections.show_projections(conn, movie_id=movie_id)
return res
@classmethod
def change_row_and_column(cls, conn, name, row, column):
cursor = conn.cursor()
null_values = cursor.execute(cls.SELECT_ROW_AND_COLUMN, (name, ))
res_id = null_values.fetchone()[0]
print(res_id)
cursor.execute(cls.UPDATE_ROW_AND_COLUMN, (row, column, res_id))
res = cursor.execute(cls.SELECT_ROW_AND_COLUMN_BY_ID, (res_id, ))
print(res.fetchone())
conn.commit()