How to use the pyathena.common.CursorIterator function in PyAthena

To help you get started, we’ve selected a few PyAthena examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github laughingman7743 / PyAthena / pyathena / async_cursor.py View on Github external
def arraysize(self, value):
        if value <= 0 or value > CursorIterator.DEFAULT_FETCH_SIZE:
            raise ProgrammingError('MaxResults is more than maximum allowed length {0}.'.format(
                CursorIterator.DEFAULT_FETCH_SIZE))
        self._arraysize = value
github laughingman7743 / PyAthena / pyathena / result_set.py View on Github external
return self._result_set.encryption_option

    @property
    def kms_key(self):
        if not self.has_result_set:
            return None
        return self._result_set.kms_key

    @property
    def work_group(self):
        if not self.has_result_set:
            return None
        return self._result_set.work_group


class AthenaResultSet(CursorIterator):

    def __init__(self, connection, converter, query_execution, arraysize, retry_config):
        super(AthenaResultSet, self).__init__(arraysize=arraysize)
        self._connection = connection
        self._converter = converter
        self._query_execution = query_execution
        assert self._query_execution, 'Required argument `query_execution` not found.'
        self._retry_config = retry_config

        self._meta_data = None
        self._rows = collections.deque()
        self._next_token = None

        if self._query_execution.state == AthenaQueryExecution.STATE_SUCCEEDED:
            self._rownumber = 0
            self._pre_fetch()
github laughingman7743 / PyAthena / pyathena / async_cursor.py View on Github external
def __init__(self, connection, s3_staging_dir, schema_name, work_group,
                 poll_interval, encryption_option, kms_key, converter, formatter,
                 retry_config, max_workers=(cpu_count() or 1) * 5,
                 arraysize=CursorIterator.DEFAULT_FETCH_SIZE):
        super(AsyncCursor, self).__init__(
            connection=connection,
            s3_staging_dir=s3_staging_dir,
            schema_name=schema_name,
            work_group=work_group,
            poll_interval=poll_interval,
            encryption_option=encryption_option,
            kms_key=kms_key,
            converter=converter,
            formatter=formatter,
            retry_config=retry_config)
        self._executor = ThreadPoolExecutor(max_workers=max_workers)
        self._arraysize = arraysize
github laughingman7743 / PyAthena / pyathena / common.py View on Github external
def __init__(self, **kwargs):
        super(CursorIterator, self).__init__()
        self.arraysize = kwargs.get('arraysize', self.DEFAULT_FETCH_SIZE)
        self._rownumber = None