OpenWeatherMap-API/weather_api_class.py
def query_execution(self, query_type, query_name, parameters):
        """
         Function implemented to execute queries in the API database
        :param query_type: Integer value that represents the family of queries to be executed.
            0: Current weather queries
            1: 5 days forecast
            2: UV index
        :param query_name: Name of the query as it was defined in the LIST_QUERY to be executed
        :param parameters: List with the set of parameters to be included in the query
        :return: a dictionary with the query output
        """
        query = self.query_preprocessing(query_type, query_name, parameters)
        if 'error' in query:
            return {'error': -1}
        else:
            url = "https://" + query + '&appid=' + self.api_key
            api_request = requests.get(url)
            if api_request.status_code != 200:
                print("Not possible to execute the query. Error reported by the API: {}, {}".format(api_request.json()['message'], api_request.json()['cod']))
                return {'error': -1}
            else:
                return api_request.json()

         Function implemented to execute queries in the API database
        :param query_type: Integer value that represents the family of queries to be executed.
            0: Current weather queries
            1: 5 days forecast
            2: UV index
        :param query_name: Name of the query as it was defined in the LIST_QUERY to be executed
        :param parameters: List with the set of parameters to be included in the query
        :return: a dictionary with the query output
        
Function implemented to execute queries in the API database
Function implemented to execute queries in the API database
def query_execution(self, query_type, query_name, parameters):
        query = self.query_preprocessing(query_type, query_name, parameters)
        if 'error' in query:
            return {'error': -1}
        else:
            url = "https://" + query + '&appid=' + self.api_key
            api_request = requests.get(url)
            if api_request.status_code != 200:
                print("Not possible to execute the query. Error reported by the API: {}, {}".format(api_request.json()['message'], api_request.json()['cod']))
                return {'error': -1}
            else:
                return api_request.json()
def query_execution ( self , query_type , query_name , parameters ) : query = self . query_preprocessing ( query_type , query_name , parameters ) if 'error' in query : return { 'error' : - 1 } else : url = "https://" + query + '&appid=' + self . api_key api_request = requests . get ( url ) if api_request . status_code != 200 : print ( "Not possible to execute the query. Error reported by the API: {}, {}" . format ( api_request . json ( ) [ 'message' ] , api_request . json ( ) [ 'cod' ] ) ) return { 'error' : - 1 } else : return api_request . json ( )
Function implemented to execute queries in the API database
Function implemented to execute queries in the API database
"""
         Function implemented to execute queries in the API database
        :param query_type: Integer value that represents the family of queries to be executed.
            0: Current weather queries
            1: 5 days forecast
            2: UV index
        :param query_name: Name of the query as it was defined in the LIST_QUERY to be executed
        :param parameters: List with the set of parameters to be included in the query
        :return: a dictionary with the query output
        """
a dictionary with the query output
a dictionary with the query output
self
query_type
Integer value that represents the family of queries to be executed.
0: Current weather queries
1: 5 days forecast
2: UV index
Integer value that represents the family of queries to be executed . 0 : Current weather queries 1 : 5 days forecast 2 : UV index
query_name
Name of the query as it was defined in the LIST_QUERY to be executed
Name of the query as it was defined in the LIST_QUERY to be executed
parameters
List with the set of parameters to be included in the query
List with the set of parameters to be included in the query