def get_sells_model_from_db(): database = Database() get_data = database.fetch_all_data(GET_SELLS_MODEL_QUERY)[0] database.close_connection() unpickled_model = ModelStorage.__get_unpickled(get_data[1]) unpickled_scalers_tuple = ModelStorage.__get_tuple_unpickled( (get_data[2], get_data[3])) return unpickled_model, unpickled_scalers_tuple, get_data[4]
def _fetch_all_data(self, query: str, named_values: List[str]): try: database = Database() data = database.fetch_all_data(query) self.__handle_data(data, named_values) except: self._response = self._build_response(data=jsonify( {"message": "Internal server error"}), status_code=500) finally: database.close_connection()
def count_advise_items(): database = Database() database.create_table(CREATE_ADVICE_TABLE_QUERY) counter = database.fetch_all_data(GET_ITEMS_COUNTER_QUERY)[0][0] database.close_connection() return counter
def count_sell_items(): database = Database() database.create_table(CREATE_SELL_DATA_QUERY) counter = database.fetch_all_data(GET_SELLS_COUNT_QUERY)[0][0] database.close_connection() return counter
def get_stocks_to_offers_counter(self): database = Database() data = database.fetch_all_data(STOCK_TO_OFFER_ALL_QUERY) self.__handle_stock_to_offer_dict(data) return self._response