def get_enb(self): session = DBLoader().create_session() try: enb_ = session.query(UEDAO.CLASS.enbIPS1U).distinct().all() enb = [] for ip in enb_: enb.append(ip[0]) return enb except Exception: session.rollback() raise finally: session.close()
def get_all_locations(self): session = DBLoader().create_session() try: locations_ = session.query( VirtualMachineDAO.CLASS.location).distinct().all() locations = [] for l in locations_: locations.append(l[0]) return locations except Exception: session.rollback() raise finally: session.close()
def query_by_multiple_filters(self, table, *filter_by, clean=True, **kwargs): session = DBLoader().create_session() try: objs = session.query(table).filter_by(**kwargs).all() response = [] for row in objs: r = dict(zip(table.columns.keys(), row)) if clean: self.__clean_filter__(r, table, *filter_by) response.append(r) return response except Exception: session.rollback() raise finally: session.close()