In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how Python3 accesses Impala in non-Kerberos environment through JDBC. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
1. Test environment
1.CM5.14.3 and CDH5.14.2
2.Redhat7.4
3.Python 3.6.5
two。 Preparation and description of pre-environment
Before using Impyla to access Hive, you need to install dependent packages for Python. The list of dependent packages to be installed is as follows:
Six
Bit_array
Impyla
Thrift
Thrift_sasl==0.2.0
(can slide left and right)
The installation directory of 1.Python3 is in / opt/cloudera/anaconda3
two。 Upgrade the pip version of Python
[root@cdh02] # / opt/cloudera/anaconda3/bin/pip install-- upgrade pip
(can slide left and right)
3. Install the above dependency packages using Python3's pip
/ opt/cloudera/anaconda3/bin/pip install six
/ opt/cloudera/anaconda3/bin/pip install bit_array
/ opt/cloudera/anaconda3/bin/pip install thrift
/ opt/cloudera/anaconda3/bin/pip install thrift_sasl==0.2.0
/ opt/cloudera/anaconda3/bin/pip install impyla
(can slide left and right)
3.Python3 access Hive sample code
[root@cdh02 python_code] # vim impaly_impala.py
From impala.dbapi import connect
From impala.util import as_pandas
Conn = connect (host='cdh01.fayson.com',port=25004,database='default')
Print (conn)
Cursor = conn.cursor ()
Cursor.execute ('show databases')
Results = cursor.fetchall ()
Print (results)
Cursor.execute ('select * from ods_user limit 10')
Df = as_pandas (cursor)
Print (df)
(can slide left and right)
4. Sample run
Run the Python code on the service using the following command
[root@cdh02 python_code] # / opt/cloudera/anaconda3/bin/python impaly_impala.py
(can slide left and right)
This is the end of this article on "how Python3 accesses Impala in non-Kerberos environment through JDBC". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.