In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use the Python Impyla client to connect Hive and Impala, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Use the hive module
Pip install sasl
Pip install thrift
Pip install thrift-sasl
Pip install PyHive
[root@ip-172-31-40-242b] # more testpyhive.py
From pyhive import hive
Conn = hive.Connection (host='xxxxxxx', port=10000, database='collection',username='')
Cursor=conn.cursor ()
Cursor.execute ('select * from tb_partition limit 10')
For result in cursor.fetchall ():
Print result
[root@ip-172-31-40-242b] # python testpyhive.py
(upright 1, upright 2, upright 201707')
(upright 1, upright 2, upright 201707')
(upright 123, None, upright 201709')
(upright 123, upright 456, ugg 201709')
(upright 45678, upright 456, upright 201709')
(upright 123, None, upright 201709')
(upright 123, upright 456, ugg 201709')
(upright 45678, upright 456, upright 201709')
(upright 123, None, upright 201709')
(upright 123, upright 456, ugg 201709')
Official API: https://pypi.org/project/PyHive/
How to use Python Impyla client to connect Hive and Impala#-*-coding:utf-8-*-from impala.dbapi import connectconn = connect (host='172.31.46.109',port=10000,database='collection',auth_mechanism='PLAIN') print (conn) cursor = conn.cursor () # param =''SET hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;SET hive.support.concurrency=true '' cursor.execute (param) cursor.execute ('SELECT uid FROM redefine_collection where uid=4028 limit 10') print cursor.description # prints the result set's schemaresults = cursor.fetchall () print results## Python connection Impala (ImpalaTest.py) # # from impala.dbapi importconnect## conn = connect (host='ip-172-31-26-80. APL southeastMI 1.compute.calculation' Port=21050) # # print (conn) # # cursor = conn.cursor () # cursor.execute ('show databases') # # print cursor.description # prints the result set's schema## results = cursor.fetchall () # print (results) # # cursor.execute (' SELECT * FROM test limit 10') # # print cursor.description # prints the result set's schema## results = cursor.fetchall () # # print (results) Thank you for reading this article carefully I hope the article "how to use Python Impyla client to connect Hive and Impala" shared by the editor will be helpful to you. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.