def getCards(filters, order): conn = bd_connect() cursor = conn.cursore() if filters == '' & order == '': cursor.execute( 'SELECT id, title, description, status, type, priority, assignee, reporter, workLog, comments FROM public."Card"' ) dict_like_arr = [] for row in cursor.fetchall(): if row != []: new_dict = { 'id': row[0], 'title': row[1], 'description': row[2], 'type': row[3], 'priority': row[4], 'assignee': row[5], 'reporter': row[6], 'workLog': row[7], 'comments': row[8] } dict_like_arr.append(new_dict) close_connect_cursor(conn, cursor) return dict_like_arr
def remove(self): try: conn = bd_connect() cursor = conn.cursore() cursor.execute(f"""DELETE FROM public."Card" WHERE id={self.__id}""") conn.commit() close_connect_cursor(conn, cursor) return True except: return None
def update(self): try: conn = bd_connect() cursor = conn.cursore() cursor.execute(f"""UPDATE public."Priorities" SET title='{self.title}', order={self.order} WHERE id={self.id}""") conn.commit() close_connect_cursor(conn, cursor) return True except: return None
def create(self): try: conn = bd_connect() cursor = conn.cursore() cursor.execute( f"""INSERT INTO public."Priorities" (id, title, order) VALUES ({self.__id}, '{self.__title}', {self.__order})""" ) conn.commit() close_connect_cursor(conn, cursor) return True except: return None
def create(self): try: conn = bd_connect() cursor = conn.cursore() cursor.execute( f"""INSERT INTO public."Card" (id, title, description, status, type, priority, assignee, reporter, workLog, comments) VALUES ({self.__id}, '{self.__title}', '{self.__description}' {self.__status}, {self.__type}, {self.__priority}, {self.__assignee} {self.__reporter}, {self.__workLog}, {self.__comments})""" ) conn.commit() close_connect_cursor(conn, cursor) return True except: return None
def getProperty(): conn = bd_connect() cursor = conn.cursore() cursor.execute('SELECT * FROM public."Priorities"') dict_like_arr = [] for row in cursor.fetchall(): if row != []: dict_like_arr.append({ 'id': row[0], 'title': row[1], 'order': row[2] }) close_connect_cursor(conn, cursor) return dict_like_arr
def update(self): try: conn = bd_connect() cursor = conn.cursore() cursor.execute(f"""UPDATE public."Card" SET title='{self.__title}', description='{self.__description}', status={self.__status}, type={self.__type}, priority={self.__priority}, assignee={self.__assignee}, reporter={self.__reporter}, workLog={self.__workLog}, comments={self.__comments} WHERE id={self.__id}""") conn.commit() close_connect_cursor(conn, cursor) return True except: return None
def createCard(creation_fields): conn = bd_connect() cursor = conn.cursore() id = 123 card = Card(id) cursor.execute('''SELECT id FROM public."Statuses"' WHEN id=1''') origin_status = cursor.fetch() card.set_status(origin_status[0]) card.set_title(creation_fields['title']) card.set_type(creation_fields['type']) card.set_assignee(creation_fields['assignee']) card.set_reporter(creation_fields['reporter']) card.set_description(creation_fields['description']) card.set_priority(creation_fields['priority']) close_connect_cursor(conn, cursor) return card.create()