How to use the pyathena.result_set.AthenaPandasResultSet 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 / tests / test_pandas_cursor.py View on Github external
def test_arraysize_default(self, cursor):
        self.assertEqual(cursor.arraysize, AthenaPandasResultSet.DEFAULT_FETCH_SIZE)
github laughingman7743 / PyAthena / pyathena / result_set.py View on Github external
def __init__(self, connection, converter, query_execution, arraysize, retry_config):
        super(AthenaPandasResultSet, self).__init__(
            connection=connection,
            converter=converter,
            query_execution=query_execution,
            arraysize=1,  # Fetch one row to retrieve metadata
            retry_config=retry_config)
        self._arraysize = arraysize
        self._client = self._connection.session.client(
            's3', region_name=self._connection.region_name, **self._connection._client_kwargs)
        if self._query_execution.state == AthenaQueryExecution.STATE_SUCCEEDED:
            self._df = self._as_pandas()
        else:
            import pandas as pd
            self._df = pd.DataFrame()
        self._iterrows = self._df.iterrows()
github laughingman7743 / PyAthena / pyathena / pandas_cursor.py View on Github external
def execute(self, operation, parameters=None, work_group=None, s3_staging_dir=None,
                cache_size=0):
        self._reset_state()
        self._query_id = self._execute(operation,
                                       parameters=parameters,
                                       work_group=work_group,
                                       s3_staging_dir=s3_staging_dir,
                                       cache_size=cache_size)
        query_execution = self._poll(self._query_id)
        if query_execution.state == AthenaQueryExecution.STATE_SUCCEEDED:
            self._result_set = AthenaPandasResultSet(
                self._connection, self._converter, query_execution, self.arraysize,
                self._retry_config)
        else:
            raise OperationalError(query_execution.state_change_reason)
        return self