【数据平台】基于pyhs2库Python作为client driver连接HiveServer
生活随笔
收集整理的這篇文章主要介紹了
【数据平台】基于pyhs2库Python作为client driver连接HiveServer
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、安裝pyhs2
A Python client driver for HiveServer2 is available at https://github.com/BradRuderman/pyhs2 (thanks, Brad). It includes all the required packages such as SASL and Thrift wrappers.The driver has been certified for use with Python 2.6 and newer.
我的環境還需要提前安裝VCForPython27,下載地址:https://www.microsoft.com/en-us/download/details.aspx?id=44266
2、參考代碼:
import pyhs2with pyhs2.connect(host='localhost',port=10000,authMechanism="PLAIN",user='root',password='test',database='default') as conn:with conn.cursor() as cur:#Show databasesprint cur.getDatabases()#Execute querycur.execute("select * from table")#Return column info from queryprint cur.getSchema()#Fetch table resultsfor i in cur.fetch():print i參考地址:https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2#SettingUpHiveServer2-PythonClientDriver
也可以考慮pyhive,github地址:https://github.com/dropbox/PyHive
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的【数据平台】基于pyhs2库Python作为client driver连接HiveServer的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【数据平台】Eclipse+Scala远
- 下一篇: websocket python爬虫_p