zoukankan      html  css  js  c++  java
  • pyhive连接hive(失败)

    一、安装pyhive

    pip install sasl(需要来下载至本地安装:https://download.lfd.uci.edu/pythonlibs/q4hpdf1k/sasl-0.2.1-cp37-cp37m-win_amd64.whl)
    pip install thrift
    pip install thrift-sasl

    pip install PyHive

    二、编码

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    from pyhive import hive
    
    
    class PyHive(object):
    
        def __init__(self):
            self.host = 'node06.research.com'
            self.port = 10000
            self.username = 'root'
            self.database = 'default'
            self.conn_hive()
    
        def conn_hive(self):
            conn = hive.Connection(host=self.host, port=self.port, username=self.username, database=self.database)
            return conn.cursor()
    
        def inst_hive(self):
            pass
    
        def select_hive(self, table):
            return self.conn_hive().execute("select * from " + table + " limit 10")
    
        def close_conn(self):
            return self.conn_hive().close()
    
    
    if __name__ == "__main__":
        test_hie = PyHive()
        try:
            result = test_hie.select_hive('default.kylin_sales')
            for res in result:
                print(res)
    
        except ConnectionError as e:
            print(e)
        finally:
            test_hie.close_conn()

    三、异常

    Traceback (most recent call last):
      File "D:/WorkSpace/Python/PyHive/conn_hive.py", line 31, in <module>
        test_hie = PyHive()
      File "D:/WorkSpace/Python/PyHive/conn_hive.py", line 14, in __init__
        self.conn_hive()
      File "D:/WorkSpace/Python/PyHive/conn_hive.py", line 17, in conn_hive
        conn = hive.Connection(host=self.host, port=self.port, username=self.username, database=self.database)
      File "C:Anaconda3libsite-packagespyhivehive.py", line 192, in __init__
        self._transport.open()
      File "C:Anaconda3libsite-packages	hrift_sasl\__init__.py", line 79, in open
        message=("Could not start SASL: %s" % self.sasl.getError()))
    thrift.transport.TTransport.TTransportException: Could not start SASL: b'Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2'
    
    Process finished with exit code 1

    最终没有找到解决方法。

    https://ask.hellobi.com/blog/ysfyb/18251

  • 相关阅读:
    Maven:Maven Wrapper
    ue4 shooterGame 第一步 搭建git linux服务器
    淌水 UE4的shootergame 案例 准备
    cesium+ geoserverTerrainProvide+png展示3D高程图展示
    geoserver使用curl发布 imagemosaic
    three.js 根据png生成heightmap
    github中cesium-terrain-builder和cesium-terrain-server使用
    geoServer 发布geoTiff格式的DEM数据
    NetCDF 入门
    java生成base64编码的png
  • 原文地址:https://www.cnblogs.com/shwang/p/12088216.html
Copyright © 2011-2022 走看看