Example #1
0
 def do_query(self, select_statement):
     """
     performs a query using sql query statement
     
     """
     result_json = OperationHelper.request_select_statement(
         self.server_url, select_statement)
     result = pd.read_json(result_json.text)
     print(result.to_string())
Example #2
0
 def __init__(self, data_type, tmp_files, _uuid, server_url):
     cmd.Cmd.__init__(self)
     if not data_type in DATA_TYPE_MAPPING.keys():
         print("data_type must be in {0}".format(
             list(DATA_TYPE_MAPPING.keys())))
         return None
     self.class_id = data_type
     self.data_type = DATA_TYPE_MAPPING[data_type]
     self._uuid = _uuid
     self.server_url = server_url
     request_json_result = OperationHelper.request_select_statement(
         self.server_url, self.QUERY_TEMPLATE.format(data_type, self._uuid))
     request_json_result = json.loads(request_json_result.text)
     df_request_result = pd.DataFrame(request_json_result)
     if df_request_result.shape[0] != 1:
         print("number of rows : {0} for uuid {1}".format(
             df_request_result.shape[0], _uuid))
     self.past_data_element = df_request_result.iloc[0].to_dict()
     self.current_data_element = self.past_data_element.copy()
     self.tmp_files = tmp_files