Exemple #1
0
 def printMovieTimes(self, day_id):
     dbConn = DBConnection()
     cur = dbConn.connection()
     query = "SELECT id,time FROM movie_timings where day_id = ?"
     for row in cur.execute(query, day_id):
         print("[" + str(row[0]) + "]", "\t", row[1])
     cur.close()
Exemple #2
0
 def printMovieDays(self, movie_id):
     dbConn = DBConnection()
     cur = dbConn.connection()
     query = "SELECT id,day FROM movie_days where movie_id = ?"
     for row in cur.execute(query, movie_id):
         print("[" + str(row[0]) + "]", "\t", row[1])
     cur.close()
Exemple #3
0
 def getBookedSeatNos(self, time_id):
     dbConn = DBConnection()
     conn = dbConn.connection()
     cur = conn.cursor()
     seat_no = list()
     query = "SELECT row,col from movie_booking where time_id = ?"
     for row in cur.execute(query, time_id):
         seat_no.append(row)
     return seat_no
Exemple #4
0
 def printMovieList(self):
     dbConn = DBConnection()
     cur = dbConn.connection()
     print(
         "#########################\n#\tMovies \t\t#\n#########################"
     )
     query = "SELECT * FROM movies"
     for row in cur.execute(query):
         print("[" + str(row[0]) + "]", "\t", row[1])
     cur.close()
Exemple #5
0
 def getMovieTitle(self, id):
     dbConn = DBConnection()
     conn = dbConn.connection()
     cur = conn.cursor()
     query = "SELECT title from movies where id = ?"
     cur.execute(query, id)
     row = cur.fetchone()
     if row:
         return row[0]
     else:
         return False
Exemple #6
0
 def getMovieTime(self, id, dayID):
     dbConn = DBConnection()
     conn = dbConn.connection()
     cur = conn.cursor()
     query = "SELECT time from movie_timings where id = {0} and day_id = {1}".format(
         id, dayID)
     cur.execute(query)
     row = cur.fetchone()
     if row:
         return row[0]
     else:
         return False
Exemple #7
0
 def getMovieDay(self, id, movieID):
     dbConn = DBConnection()
     conn = dbConn.connection()
     cur = conn.cursor()
     query = "SELECT day from movie_days where id = {0} AND movie_id = {1}".format(
         id, movieID)
     cur.execute(query)
     row = cur.fetchone()
     if row:
         return row[0]
     else:
         return False
Exemple #8
0
 def bookTicket(self, time_id, seatnos, name):
     dbConn = DBConnection()
     conn = dbConn.connection()
     cur = conn.cursor()
     for seat in seatnos:
         (row, col) = seat
         query = "INSERT INTO movie_booking(time_id,row,col,username) values({0},{1},{2},'{3}')".format(
             time_id, row, col, str(name))
         if cur.execute(query):
             conn.commit()
         else:
             return False
     return True
Exemple #9
0
def install():

    dbConn = DBConnection()
    conn = dbConn.connection()
    cur = conn.cursor()

    #creating movie table

    cur.execute(
        '''CREATE TABLE IF NOT EXISTS movies(ID INTEGER PRIMARY KEY AUTOINCREMENT, TITLE TEXT NOT NULL)'''
    )

    cur.execute("INSERT INTO movies(TITLE) \
            VALUES ('Die Hard 4.0')")

    cur.execute("INSERT INTO movies(TITLE) \
            VALUES ('John Wick')")

    cur.execute("INSERT INTO movies(TITLE) \
            VALUES ('John Wick 2')")

    cur.execute(
        '''CREATE TABLE IF NOT EXISTS movie_days(ID INTEGER PRIMARY KEY AUTOINCREMENT, movie_id INTEGER NOT NULL, day TEXT)'''
    )

    cur.execute("INSERT INTO movie_days(movie_id,day) \
            VALUES (1,'TUE')")
    cur.execute("INSERT INTO movie_days(movie_id,day) \
            VALUES (1,'WED')")
    cur.execute("INSERT INTO movie_days(movie_id,day) \
            VALUES (1,'FRI')")
    cur.execute("INSERT INTO movie_days(movie_id,day) \
            VALUES (2,'MON')")
    cur.execute("INSERT INTO movie_days(movie_id,day) \
            VALUES (2,'WED')")
    cur.execute("INSERT INTO movie_days(movie_id,day) \
            VALUES (2,'THUR')")
    cur.execute("INSERT INTO movie_days(movie_id,day) \
            VALUES (2,'FRI')")
    cur.execute("INSERT INTO movie_days(movie_id,day) \
            VALUES (3,'FRI')")

    cur.execute(
        '''CREATE TABLE IF NOT EXISTS movie_timings(ID INTEGER PRIMARY KEY AUTOINCREMENT, day_id INTEGER NOT NULL, time TEXT)'''
    )
    cur.execute(
        '''CREATE TABLE IF NOT EXISTS movie_booking ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `time_id` INTEGER NOT NULL, `row` INTEGER NOT NULL, `col` INTEGER NOT NULL, `username` TEXT NOT NULL )'''
    )
    cur.execute("INSERT INTO movie_timings(day_id,time) \
            VALUES (1,'09:00')")
    cur.execute("INSERT INTO movie_timings(day_id,time) \
            VALUES (1,'11:30')")
    cur.execute("INSERT INTO movie_timings(day_id,time) \
            VALUES (2,'14:00')")
    cur.execute("INSERT INTO movie_timings(day_id,time) \
            VALUES (2,'20:00')")
    cur.execute("INSERT INTO movie_timings(day_id,time) \
            VALUES (3,'22:00')")
    cur.execute("INSERT INTO movie_timings(day_id,time) \
            VALUES (3,'22:00')")
    cur.execute("INSERT INTO movie_timings(day_id,time) \
            VALUES (4,'22:00')")
    cur.execute("INSERT INTO movie_timings(day_id,time) \
            VALUES (4,'22:00')")
    cur.execute("INSERT INTO movie_timings(day_id,time) \
            VALUES (5,'22:00')")
    cur.execute("INSERT INTO movie_timings(day_id,time) \
            VALUES (6,'22:00')")
    cur.execute("INSERT INTO movie_timings(day_id,time) \
            VALUES (7,'22:00')")
    cur.execute("INSERT INTO movie_timings(day_id,time) \
            VALUES (8,'22:00')")
    conn.commit()
    conn.close()