def build_dict_for_cursor(self, cursor_object: CursorObject): column_names_list = cursor_object.get_columns() data = [ dict(zip(column_names_list, row)) for row in cursor_object.get_data() ] return data[0]
def data_as_cursor_list_multiple_rs(self): """ :Description: This creates the cursorObject from the cursor and returns to the callee with list of cursor objects This should be used for the multiple result set always :return: list of dictionary, which contains the CursorObject """ cursor_list = [] while 1: data = self.cursor.fetchall() if len(data) > 0: cursor_obj = CursorObject() cursor_obj.columns = [x[0] for x in self.cursor.description] cursor_obj.data = data cursor_list.append(cursor_obj) if self.cursor.nextset() is None: break if self.cursor.description is None: break else: break return cursor_list
def __init__(self, ext_params={}, event_type=None): self.cursor = None self.sp_name = None self.params = None self.data = [] self.db_error_code = ErrorCodes.DATABASE_ERROR self.general_error_code = ErrorCodes.GENERAL_ERROR self.current_db_type = None self.read_db_names = None self.current_read_db = None self.params_list = [] self.cursor_object = CursorObject() self.ext_params = ext_params self.event_type = event_type
def data_as_cursor_dict_multiple_rs(self): """ :Description: This creates the cursorObject from the cursor and returns to the callee This should be used for the multiple result set always :return: list of dictionary, which contains the CursorObject """ count = 1 dict_ = {} while 1: data = self.cursor.fetchall() if len(data) > 0: cursor_obj = CursorObject() cursor_obj.columns = [x[0] for x in self.cursor.description] cursor_obj.data = data dict_[str(count)] = cursor_obj count = count + 1 if self.cursor.nextset() is None: break if self.cursor.description is None: break else: break self.data.append(dict_) return self.data