使用impyla连接TDH平台inceptor

基于python2.7

安装

impyla安装依赖以下模块:

  • six
  • bit_array
  • thrift
    为支持hive和kerberos,还需要以下模块:
  • thrift_sasl
  • sasl
    除此之外,还可以使用pandas模块来实现对连接执行语句后的结果进行结构化处理。
    使用pytest,对安装的impyla进行测试,验证安装没有问题。
  • pandas
  • pytest
    其中:
    pandas依赖以下安装包:
    pytz python-dateutil numpy six
    pytest 依赖以下安装包:
    atomicwrites attrs funcsigs more-itertools pathlib2 pluggy py scandir
    在内网环境下安装这些软件,真的很麻烦

安全模式下连接

经过测试,impyla可以连接配置安全认证的inceptor,在连接参数指定上选择:
auth_mechanism="PLAIN"

连接代码:

conn = connect(host='inceptor.server.ip', port=10000,user="dw",password="123456",database="default",auth_mechanism="PLAIN")
cursor = conn.cursor()

执行数据库命令:

cursor.execute('show databases')
print cursor.description # prints the result set's schema
results = cursor.fetchall()

执行DDL语句:

cursor.execute('create table test( a string)')
print cursor.description  
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容