How to use the pyhive.exc function in PyHive

To help you get started, we’ve selected a few PyHive 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 GoogleCloudPlatform / professional-services / tools / hive-bigquery / hive_component.py View on Github external
Returns:
            List: Results of the query.
        """

        cursor = self.get_cursor()
        try:
            if isinstance(query_cmds, list):
                for query in query_cmds:
                    cursor.execute(query)
            else:
                cursor.execute(query_cmds)

            try:
                results = cursor.fetchall()
            except exc.ProgrammingError:
                results = []
            finally:
                return results

        except exc.OperationalError as error:
            logger.error("Hive Query {} execution failed".format(str(query_cmds)))
            raise custom_exceptions.HiveExecutionError from error
github apache / incubator-superset / superset / db_engine_specs.py View on Github external
def fetch_data(cls, cursor, limit):
        import pyhive
        from TCLIService import ttypes
        state = cursor.poll()
        if state.operationState == ttypes.TOperationState.ERROR_STATE:
            raise Exception('Query error', state.errorMessage)
        try:
            return super(HiveEngineSpec, cls).fetch_data(cursor, limit)
        except pyhive.exc.ProgrammingError:
            return []
github apache / incubator-superset / superset / db_engine_specs / hive.py View on Github external
def fetch_data(cls, cursor, limit: int) -> List[Tuple]:
        import pyhive
        from TCLIService import ttypes

        state = cursor.poll()
        if state.operationState == ttypes.TOperationState.ERROR_STATE:
            raise Exception("Query error", state.errorMessage)
        try:
            return super(HiveEngineSpec, cls).fetch_data(cursor, limit)
        except pyhive.exc.ProgrammingError:
            return []
github GoogleCloudPlatform / professional-services / tools / hive-bigquery / hive_component.py View on Github external
cursor = self.get_cursor()
        try:
            if isinstance(query_cmds, list):
                for query in query_cmds:
                    cursor.execute(query)
            else:
                cursor.execute(query_cmds)

            try:
                results = cursor.fetchall()
            except exc.ProgrammingError:
                results = []
            finally:
                return results

        except exc.OperationalError as error:
            logger.error("Hive Query {} execution failed".format(str(query_cmds)))
            raise custom_exceptions.HiveExecutionError from error
github dropbox / PyHive / pyhive / common.py View on Github external
def escape_args(self, parameters):
        if isinstance(parameters, dict):
            return {k: self.escape_item(v) for k, v in parameters.items()}
        elif isinstance(parameters, (list, tuple)):
            return tuple(self.escape_item(x) for x in parameters)
        else:
            raise exc.ProgrammingError("Unsupported param format: {}".format(parameters))