class NewsModel(): _DB_TABLE = 'newscraper' _LOG = logging.getLogger("NewsModel") def __init__(self, host, port, user, password, db_name): self.sqlmodel = SQLModel(host, port, user, password, db_name) def retrieve_news(self): news_query = f"SELECT url, publicationDate, newspaper, title, description, image FROM {NewsModel._DB_TABLE};" news_array = self.sqlmodel.retrieve(news_query) return news_array
class OrganizationsModel: _DB_TABLE = 'organizations' _DB_TOKEN_TABLE = 'organizations_tokens' _LOG = logging.getLogger("OrganizationsModel") def __init__(self, host, port, user, password, db_name): self.sqlmodel = SQLModel(host, port, user, password, db_name) def retrieve_organizations(self): orgs_query = f"SELECT id, url, name, description FROM {OrganizationsModel._DB_TABLE};" orgs_array = self.sqlmodel.retrieve(orgs_query) for org in orgs_array: del org['id'] return orgs_array