天天看點

使用PyHive操作Hive

使用PyHive操作Hive

廢話

搜了一下,看到了StackOverFlow的回答,試了一下前兩個方案,感覺第二個更簡潔,這裡記錄一下,更詳細的見參考。

安裝依賴
pip install sasl
pip install thrift
pip install thrift-sasl
pip install PyHive
           
操作
from pyhive import hive
conn = hive.Connection(host='xxxx', port=10000, username='xxx', database='default')
cursor.execute('select * from url_log limit 10')
for result in cursor.fetchall():
    print result
           
參考
  • https://github.com/dropbox/PyHive
  • https://stackoverflow.com/questions/21370431/how-to-access-hive-via-python