【数据平台】基于pyhs2库Python作为client driver连接HiveServer
生活随笔
收集整理的這篇文章主要介紹了
【数据平台】基于pyhs2库Python作为client driver连接HiveServer
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
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.
我的環(huán)境還需要提前安裝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
《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的【数据平台】基于pyhs2库Python作为client driver连接HiveServer的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 【数据平台】Eclipse+Scala远
- 下一篇: 【数据平台】基于pymysql库pyth