インストールしましたが、
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
ここから Hortonworks サンドボックスをダウンロードし、別のサーバーで使用しています。
注:私もこれを経験しましたが、受け入れられた答えは私にとってはうまくいきません.ハイブからThriftHiveをインポートすると、ハイブがインストールされているにもかかわらずインポートエラーが発生するためです. そこで、pyhive または sqlalchemy を使用することにしました
ハイブに接続してクエリを簡単に実行するにはどうすればよいですか?