新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

Python3如何通过JDBC访问非Kerberos环境的Impala

这篇文章将为大家详细讲解有关Python3如何通过JDBC访问非Kerberos环境的Impala,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

我们提供的服务有:成都网站制作、网站建设、外贸网站建设、微信公众号开发、网站优化、网站认证、志丹ssl等。为上1000家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的志丹网站制作公司

1.测试环境

1.CM5.14.3和CDH5.14.2

2.Redhat7.4

3.Python 3.6.5

2.前置环境准备及说明


在使用Impyla访问Hive前,需要安装Python的依赖包,具体需要安装的依赖包列表如下:

six
bit_array
impyla
thrift
thrift_sasl==0.2.0

(可左右滑动)

1.Python3的安装目录在/opt/cloudera/anaconda3

Python3如何通过JDBC访问非Kerberos环境的Impala

2.升级Python的pip版本

[root@cdh02 ~]# /opt/cloudera/anaconda3/bin/pip install --upgrade pip

(可左右滑动)

Python3如何通过JDBC访问非Kerberos环境的Impala

3.使用Python3的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

(可左右滑动)

Python3如何通过JDBC访问非Kerberos环境的Impala

Python3如何通过JDBC访问非Kerberos环境的Impala

Python3如何通过JDBC访问非Kerberos环境的Impala

3.Python3访问Hive示例代码


[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)

(可左右滑动)

Python3如何通过JDBC访问非Kerberos环境的Impala

4.示例运行


在服务上使用如下命令运行Python代码

[root@cdh02 python_code]# /opt/cloudera/anaconda3/bin/python impaly_impala.py 

(可左右滑动)

Python3如何通过JDBC访问非Kerberos环境的Impala

关于“Python3如何通过JDBC访问非Kerberos环境的Impala”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。


标题名称:Python3如何通过JDBC访问非Kerberos环境的Impala
网站地址:http://www.wjwzjz.com/article/gsecjs.html
在线咨询
服务热线
服务热线:028-86922220
TOP