Python链接impala
Python连接impala记录
安装驱动包impyla
pip install impyla
测试连接脚本
# coding: utf-8
from impala.dbapi import connect
conn = connect(host='10.24.66.36', port=21051, user='user', password='pwd', auth_mechanism='PLAIN')
cursor = conn.cursor()
cursor.execute('SHOW TABLES')
results = cursor.fetchall()
print(results)
superset连接impala的uri:
impala://10.24.66.36:21051/dbname?auth_mechanism=PLAIN&password=pwd&user=user
可能出现问题
AttributeError: 'TBufferedTransport' object has no attribute 'trans'
原因: 貌似是依赖包thrift版本问题
解决方案: 安装thrift 0.9.3版本可以解决
pip install thrift==0.9.3
参考: * https://github.com/cloudera/impyla/issues/235 * https://github.com/cloudera/impyla/issues/234