def Get(filterExpression=None): connection, cursor = basehandler.DbConnect() myQuery = "SELECT * FROM USER_DBT" if filterExpression is None: cursor = basehandler.DbExecute(myQuery, connection, cursor) else: myQuery += filterExpression.GetWhere() cursor = basehandler.DbExecute(myQuery, connection, cursor, filterExpression.GetParameters()) userList = [] for user in cursor.fetchall(): tempUser = User() tempUser.userId = user[0] tempUser.firstName = user[1] tempUser.lastName = user[2] tempUser.username = user[3] tempUser.password = user[4] tempUser.email = user[5] tempUser.userType = user[6] userList.append(tempUser) basehandler.DbClose(connection, cursor) return userList
def Get(filterExpression=None): connection, cursor = basehandler.DbConnect() myQuery = "SELECT * FROM TICKET_DBT" if filterExpression is None: cursor = basehandler.DbExecute(myQuery, connection, cursor) else: myQuery += filterExpression.GetWhere() cursor = basehandler.DbExecute(myQuery, connection, cursor, filterExpression.GetParameters()) TicketList = [] for ticket in cursor.fetchall(): tempTicket = Ticket() tempTicket.ticketId = ticket[0] tempTicket.concertId = ticket[1] tempTicket.price = ticket[2] tempTicket.avilable_ticket = ticket[3] TicketList.append(tempTicket) basehandler.DbClose(connection, cursor) return TicketList
def Get(filterExpression = None): connection, cursor = basehandler.DbConnect() myQuery = "SELECT * FROM MUSICIAN_DBT" if filterExpression is None: cursor = basehandler.DbExecute(myQuery, connection, cursor) else: myQuery += filterExpression.GetWhere() cursor = basehandler.DbExecute(myQuery, connection, cursor, filterExpression.GetParameters()) musicianList = [] for musician in cursor.fetchall(): tempMusician = Musician() tempMusician.musicianId = musician[0] tempMusician.name = musician[1] tempMusician.genre = musician[2] tempMusician.establishYear = musician[3] tempMusician.imgUrl = musician[4] tempMusician.description = musician[5] musicianList.append(tempMusician) basehandler.DbClose(connection, cursor) return musicianList
def Get(filterExpression=None): connection, cursor = basehandler.DbConnect() myQuery = "SELECT * FROM NEWS_DBT" if filterExpression is None: cursor = basehandler.DbExecute(myQuery, connection, cursor) else: myQuery += filterExpression.GetWhere() cursor = basehandler.DbExecute(myQuery, connection, cursor, filterExpression.GetParameters()) newsList = [] for news in cursor.fetchall(): tempNews = News() tempNews.newsId = news[0] tempNews.title = news[1] tempNews.musicianId = news[2] tempNews.content = news[3] tempNews.imgUrl = news[4] tempNews.createdBy = news[5] tempNews.createDate = news[6] tempNews.updateDate = news[7] newsList.append(tempNews) basehandler.DbClose(connection, cursor) return newsList
def Get(filterExpression = None): connection, cursor = basehandler.DbConnect() myQuery = "SELECT * FROM CONCERT_AREA_DBT" if filterExpression is None: cursor = basehandler.DbExecute(myQuery, connection, cursor) else: myQuery += filterExpression.GetWhere() cursor = basehandler.DbExecute(myQuery, connection, cursor, filterExpression.GetParameters()) Concert_areaList = [] for concert_area in cursor.fetchall(): tempConcert_area = Concert_area() tempConcert_area.concert_areaId = concert_area[0] tempConcert_area.name = concert_area[1] tempConcert_area.address = concert_area[2] tempConcert_area.capacity = concert_area[3] Concert_areaList.append(tempConcert_area) basehandler.DbClose(connection, cursor) return Concert_areaList
def Get(filterExpression=None): connection, cursor = basehandler.DbConnect() myQuery = "SELECT * FROM CONCERT_DBT" if filterExpression is None: cursor = basehandler.DbExecute(myQuery, connection, cursor) else: myQuery += filterExpression.GetWhere() cursor = basehandler.DbExecute(myQuery, connection, cursor, filterExpression.GetParameters()) ConcertList = [] for concert in cursor.fetchall(): tempConcert = concert() tempConcert.concertId = concert[0] tempConcert.concert_areaId = concert[1] tempConcert.musicianId = concert[2] tempConcert.date = concert[3] ConcertList.append(tempConcert) basehandler.DbClose(connection, cursor) return ConcertList
def Get(filterExpression=None): connection, cursor = basehandler.DbConnect() myQuery = "SELECT * FROM NEWSVIEW" if filterExpression is None: cursor = basehandler.DbExecute(myQuery, connection, cursor) else: myQuery += filterExpression.GetWhere() cursor = basehandler.DbExecute(myQuery, connection, cursor, filterExpression.GetParameters()) newsViewList = [] for nv in cursor.fetchall(): tempNewsView = NewsView() tempNewsView.newsId = nv[0] tempNewsView.title = nv[1] tempNewsView.musicianId = nv[2] tempNewsView.content = nv[3] tempNewsView.imgUrl = nv[4] tempNewsView.createdBy = nv[5] tempNewsView.createDate = nv[6] tempNewsView.updateDate = nv[7] tempNewsView.creatorName = nv[8] tempNewsView.musicianName = nv[9] newsViewList.append(tempNewsView) basehandler.DbClose(connection, cursor) return newsViewList
def Delete(userId): connection, cursor = basehandler.DbConnect() myQuery = "DELETE FROM USER_DBT WHERE USERID = " + str(userId) cursor = basehandler.DbExecute(myQuery, connection, cursor) basehandler.DbClose(connection, cursor) return True
def Delete(musicianId): connection, cursor = basehandler.DbConnect() myQuery = "DELETE FROM MUSICIAN_DBT WHERE MUSICIANID = " + str(musicianId) cursor = basehandler.DbExecute(myQuery, connection, cursor) basehandler.DbClose(connection, cursor) return True
def Delete(TicketId): connection, cursor = basehandler.DbConnect() myQuery = "DELETE FROM TICKET_DBT WHERE TICKETID = " + str(TicketId) cursor = basehandler.DbExecute(myQuery, connection, cursor) basehandler.DbClose(connection, cursor) return True
def Delete(newsId): connection, cursor = basehandler.DbConnect() myQuery = "DELETE FROM NEWS_DBT WHERE NEWSID = " + str(newsId) cursor = basehandler.DbExecute(myQuery, connection, cursor) basehandler.DbClose(connection, cursor) return True
def Delete(concert_areaId): connection, cursor = basehandler.DbConnect() myQuery = "DELETE FROM CONCERT_AREA_DBT WHERE CONCERT_AREAID = " + str(concert_areaId) cursor = basehandler.DbExecute(myQuery, connection, cursor) basehandler.DbClose(connection, cursor) return True
def Insert(newMusician): connection, cursor = basehandler.DbConnect() myQuery = """INSERT INTO MUSICIAN_DBT(MUSICIANNAME, MUSICIANGENRE, MUSICIANESTYEAR, MUSICIANIMGURL, MUSICIANDESC) VALUES (%s, %s, %s, %s, %s) RETURNING MUSICIANID;""" cursor = basehandler.DbExecute(myQuery, connection, cursor, (newMusician.name, newMusician.genre, newMusician.establishYear, newMusician.imgUrl, newMusician.description)) newMusician.musicianId = cursor.fetchone()[0] basehandler.DbClose(connection, cursor) return newMusician
def Update(currentConcert_area): connection, cursor = basehandler.DbConnect() myQuery = """UPDATE CONCERT_AREA_DBT SET CONCERT_AREANAME = %s, CONCERT_AREAADRESS = %s, CONCERT_AREACAPACITY = %s, WHERE CONCERT_AREAID = %s""" cursor = basehandler.DbExecute(myQuery, connection, cursor, (currentConcert_area.name, currentConcert_area.address, currentConcert_area.capacity, currentConcert_area.concert_areaId)) basehandler.DbClose(connection, cursor) return currentConcert_area
def Insert(newConcert_area): connection, cursor = basehandler.DbConnect() myQuery = """INSERT INTO CONCERT_AREA_DBT(CONCERT_AREANAME, CONCERT_AREAADRESS, CONCERT_AREACAPACITY) VALUES (%s, %s, %s) RETURNING CONCERT_AREAID;""" cursor = basehandler.DbExecute(myQuery, connection, cursor, (newConcert_area.name, newConcert_area.address, newConcert_area.capacity)) newConcert_area.concert_areaId = cursor.fetchone()[0] basehandler.DbClose(connection, cursor) return newConcert_area
def Insert(newConcert): connection, cursor = basehandler.DbConnect() myQuery = """INSERT INTO CONCERT_DBT(CONCERTCONCERT_AREAID, CONCERTMUSICIANID, CONCERTDATE) VALUES (%s, %s, %s) RETURNING CONCERTID;""" cursor = basehandler.DbExecute( myQuery, connection, cursor, (newConcert.concert_areaId, newConcert.musicianId, newConcert.date)) newConcert.concertId = cursor.fetchone()[0] basehandler.DbClose(connection, cursor) return newConcert
def Update(currentMusician): connection, cursor = basehandler.DbConnect() myQuery = """UPDATE MUSICIAN_DBT SET MUSICIANNAME = %s, MUSICIANGENRE = %s, MUSICIANESTYEAR = %s, MUSICIANIMGURL = %s, MUSICIANDESC = %s WHERE MUSICIANID = %s""" cursor = basehandler.DbExecute(myQuery, connection, cursor, (currentMusician.name, currentMusician.genre, currentMusician.establishYear, currentMusician.imgUrl, currentMusician.description, currentMusician.musicianId)) basehandler.DbClose(connection, cursor) return currentMusician
def Insert(newTicket): connection, cursor = basehandler.DbConnect() myQuery = """INSERT INTO TICKET_DBT(TICKETCONCERTID, TICKETPRICE, TICKETAVALILABLE) VALUES (%s, %s, %s) RETURNING TICKETID;""" cursor = basehandler.DbExecute( myQuery, connection, cursor, (newTicket.concertId, newTicket.price, newTicket.available_ticket)) newTicket.TicketId = cursor.fetchone()[0] basehandler.DbClose(connection, cursor) return newTicket
def Insert(newNews): connection, cursor = basehandler.DbConnect() myQuery = """INSERT INTO NEWS_DBT(NEWSTITLE, NEWSMUSICIANID, NEWSCONTENT, NEWSIMGURL, CREATEDBY) VALUES (%s, %s, %s, %s, %s) RETURNING NEWSID;""" cursor = basehandler.DbExecute( myQuery, connection, cursor, (newNews.title, newNews.musicianId, newNews.content, newNews.imgUrl, newNews.createdBy)) newNews.newsId = cursor.fetchone()[0] basehandler.DbClose(connection, cursor) return newNews
def Update(currentConcert): connection, cursor = basehandler.DbConnect() myQuery = """UPDATE CONCERT_DBT SET CONCERTCONCERT_AREAID = %s, CONCERTMUSICIANID = %s, CONCERTDATE = %s, WHERE CONCERTID = %s""" cursor = basehandler.DbExecute( myQuery, connection, cursor, (currentConcert.concert_areaId, currentConcert.musicianId, currentConcert.date, currentConcert.ConcertId)) basehandler.DbClose(connection, cursor) return currentConcert
def Insert(newUser): connection, cursor = basehandler.DbConnect() myQuery = """INSERT INTO USER_DBT(USERFIRSTNAME, USERLASTNAME, USERUSERNAME, USERPASSWORD, USEREMAIL, USERTYPE) VALUES (%s, %s, %s, %s, %s, %s) RETURNING USERID;""" cursor = basehandler.DbExecute( myQuery, connection, cursor, (newUser.firstName, newUser.lastName, newUser.username, newUser.password, newUser.email, newUser.userType)) newUser.userId = cursor.fetchone()[0] basehandler.DbClose(connection, cursor) return newUser
def Update(currentTicket): connection, cursor = basehandler.DbConnect() myQuery = """UPDATE TICKET_DBT SET TICKETCONCERTID = %s, TICKETPRICE = %s, TICKETAVAILABLE = %s, WHERE TICKETID = %s""" cursor = basehandler.DbExecute( myQuery, connection, cursor, (currentTicket.concertId, currentTicket.price, currentTicket.available_ticket, currentTicket.TicketId)) basehandler.DbClose(connection, cursor) return currentTicket
def Update(currentUser): connection, cursor = basehandler.DbConnect() myQuery = """UPDATE USER_DBT SET USERFIRSTNAME = %s, USERLASTNAME = %s, USERUSERNAME = %s, USERPASSWORD = %s, USEREMAIL = %s WHERE USERID = %s""" cursor = basehandler.DbExecute( myQuery, connection, cursor, (currentUser.firstName, currentUser.lastName, currentUser.username, currentUser.password, currentUser.email, currentUser.userId)) basehandler.DbClose(connection, cursor) return currentUser
def Update(currentNews): connection, cursor = basehandler.DbConnect() myQuery = """UPDATE NEWS_DBT SET NEWSTITLE = %s, NEWSMUSICIANID = %s, NEWSCONTENT = %s, NEWSIMGURL = %s WHERE NEWSID = %s""" cursor = basehandler.DbExecute( myQuery, connection, cursor, (currentNews.title, currentNews.musicianId, currentNews.content, currentNews.imgUrl, currentNews.newsId)) myQuery = """UPDATE NEWS_DBT SET UPDATEDATE = LOCALTIMESTAMP WHERE NEWSID =""" + str( currentNews.newsId) + ";" cursor = basehandler.DbExecute(myQuery, connection, cursor) basehandler.DbClose(connection, cursor) return currentNews