示例#1
0
    def append_result(self, result):
        """Append a result set to the list of result sets.

        :param result: Result set to add last to the list of result sets.
        """
        if not isinstance(result, ResultSet):
            raise _errors.CommandResultError(
                "Result have to be an instance of ResultSet")
        if self.error:
            raise _errors.CommandResultError(
                "Result sets cannot be added for error results")
        self.__results.append(result)
示例#2
0
    def append_row(self, row):
        """Append a row to the result set.

        The row is an array (a list or tuple) of values that should be
        added to the result set. When adding the row, it will be
        checked that the length of the row matches the number of
        columns defined for the result set and that the types of the
        values match the type given for the column.

        :param row: An array of the values to add.

        """

        # Check that the length of the row matches the number of
        # columns for the result set
        if len(row) != len(self.__columns):
            message = "Invalid row length: expected %d, was %d" % (len(
                self.__columns), len(row))
            raise _errors.CommandResultError(message)

        self.__rows.append(
            tuple(col.type(val) for col, val in zip(self.__columns, row)))