美文网首页python大数据
使用impyla连接TDH平台inceptor

使用impyla连接TDH平台inceptor

作者: 八幡大老师 | 来源:发表于2019-01-16 18:57 被阅读0次

    基于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  
    

    相关文章

      网友评论

        本文标题:使用impyla连接TDH平台inceptor

        本文链接:https://www.haomeiwen.com/subject/yaqvdqtx.html