【发布时间】:2017-02-13 18:23:31
【问题描述】:
我已经安装了,
pip install thrift
pip install PyHive
pip install thrift-sasl
和
由于pip install sasl 失败,我下载了sasl‑0.2.1‑cp27‑cp27m‑win_amd64.whl 文件并将其安装在我的Windows 8.1 PC 中。
然后我写了这段代码,
from pyhive import hive
cursor = hive.connect('192.168.1.232', port=10000, auth='NONE')
cursor.execute('SELECT * from sample_07 LIMIT 5',async=True)
print cursor.fetchall()
这给出了错误:
Traceback (most recent call last):
File "C:/DigInEngine/scripts/UserManagementService/fd.py", line 37, in <module>
cursor = hive.connect('192.168.1.232', port=10000, auth = 'NONE')
File "C:\Python27\lib\site-packages\pyhive\hive.py", line 63, in connect
return Connection(*args, **kwargs)
File "C:\Python27\lib\site-packages\pyhive\hive.py", line 104, in __init__
self._transport.open()
File "C:\Python27\lib\site-packages\thrift_sasl\__init__.py", line 72, in open
message=("Could not start SASL: %s" % self.sasl.getError()))
thrift.transport.TTransport.TTransportException: Could not start SASL: Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2
这段代码给出了,
from sqlalchemy import create_engine
engine = create_engine('hive://192.168.1.232:10000/default')
try:
connection = engine.connect()
except Exception, err:
print err
result = connection.execute('select * from sample_07;')
engine.dispose()
这个错误,
无法启动 SASL:sasl_client_start (-4) 中的错误 SASL(-4):否 可用机制:找不到回调:2
我已经从here 下载了 Hortonworks 沙盒,并在单独的服务器中使用它。
注意:我也经历了this,但接受的答案对我不起作用,因为从配置单元导入 ThriftHive 会出现导入错误,尽管我已经安装了 pip 配置单元。所以我决定使用 pyhive 或者 sqlalchemy
如何轻松连接到 hive 并执行查询?
【问题讨论】:
标签: python hadoop hive sqlalchemy pyhive