예제 #1
0
    def cursor(self,
               cursor: Optional[Type[BaseCursor]] = None,
               **kwargs) -> BaseCursor:
        if not cursor:
            cursor = self.cursor_class
        converter = kwargs.pop("converter", self._converter)
        if not converter:
            from pyathena.pandas.async_cursor import AsyncPandasCursor
            from pyathena.pandas.cursor import PandasCursor

            if cursor is PandasCursor or cursor is AsyncPandasCursor:
                converter = DefaultPandasTypeConverter()
            else:
                converter = DefaultTypeConverter()
        return cursor(connection=self,
                      s3_staging_dir=kwargs.pop("s3_staging_dir",
                                                self.s3_staging_dir),
                      poll_interval=kwargs.pop("poll_interval",
                                               self.poll_interval),
                      encryption_option=kwargs.pop("encryption_option",
                                                   self.encryption_option),
                      kms_key=kwargs.pop("kms_key", self.kms_key),
                      converter=converter,
                      formatter=kwargs.pop("formatter", self._formatter),
                      retry_config=kwargs.pop("retry_config",
                                              self._retry_config),
                      schema_name=kwargs.pop("schema_name", self.schema_name),
                      catalog_name=kwargs.pop("catalog_name",
                                              self.catalog_name),
                      work_group=kwargs.pop("work_group", self.work_group),
                      kill_on_interrupt=kwargs.pop("kill_on_interrupt",
                                                   self.kill_on_interrupt),
                      **kwargs)
예제 #2
0
 def cursor(self, cursor=None, **kwargs):
     if not cursor:
         cursor = self.cursor_class
     converter = kwargs.pop('converter', self._converter)
     if not converter:
         if cursor is PandasCursor or cursor is AsyncPandasCursor:
             converter = DefaultPandasTypeConverter()
         else:
             converter = DefaultTypeConverter()
     return cursor(connection=self,
                   s3_staging_dir=kwargs.pop('s3_staging_dir', self.s3_staging_dir),
                   schema_name=kwargs.pop('schema_name', self.schema_name),
                   work_group=kwargs.pop('work_group', self.work_group),
                   poll_interval=kwargs.pop('poll_interval', self.poll_interval),
                   encryption_option=kwargs.pop('encryption_option', self.encryption_option),
                   kms_key=kwargs.pop('kms_key', self.kms_key),
                   converter=converter,
                   formatter=kwargs.pop('formatter', self._formatter),
                   retry_config=kwargs.pop('retry_config', self._retry_config),
                   **kwargs)
예제 #3
0
 def get_default_converter(unload: bool = False) -> Union[DefaultTypeConverter, Any]:
     return DefaultTypeConverter()