首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用python使用impyla/dbapi.py连接到配置单元

无法使用python使用impyla/dbapi.py连接到配置单元
EN

Stack Overflow用户
提问于 2019-02-15 02:25:45
回答 1查看 834关注 0票数 0

我正在尝试使用python连接到hivewith default derby db:

代码语言:javascript
复制
from impala.dbapi import connect
conn = connect( host='localhost', port=10000)
cursor = conn.cursor()
cursor.execute('SELECT * FROM employee')
print cursor.description  # prints the result set's schema
results = cursor.fetchall()

但是我得到了一个错误:

代码语言:javascript
复制
Traceback (most recent call last):
  File "hivetest_b.py", line 2, in <module>
    conn = connect( host='localhost', port=10000)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/impala/dbapi.py", line 147, in connect
    auth_mechanism=auth_mechanism)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/impala/hiveserver2.py", line 758, in connect
    transport.open()
  File "/home/ubuntu/.local/lib/python2.7/site-packages/thrift/transport/TTransport.py", line 149, in open
    return self.__trans.open()
  File "/home/ubuntu/.local/lib/python2.7/site-packages/thrift/transport/TSocket.py", line 101, in open
    message=message)
thrift.transport.TTransport.TTransportException: Could not connect to localhost:10000

我的/etc/hosts中的条目是:

代码语言:javascript
复制
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

我正在使用默认的hive-site.xml和defult derby数据库来运行我的hive。当我在shell中运行hive时,它会向我显示该表:

代码语言:javascript
复制
hive> show databases;
OK
default
test
test_db
Time taken: 0.937 seconds, Fetched: 3 row(s)
hive> show tables;
OK
employee
Time taken: 0.054 seconds, Fetched: 1 row(s)
hive> describe employee;
OK
empname                 string
age                     int
gender                  string
income                  float
department              string
dept                    string

# Partition Information
# col_name              data_type               comment

dept                    string
Time taken: 0.451 seconds, Fetched: 11 row(s)

我不确定我到底错过了什么。任何快速参考/指针都将不胜感激。

你好,Bhupesh

EN

回答 1

Stack Overflow用户

发布于 2019-02-15 04:26:17

您可以使用以下命令检查和验证端口:

代码语言:javascript
复制
hive> set hive.server2.thrift.port;

并尝试使用0.0.0.0127.0.0.1而不是localhost作为连接的主机。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54696850

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档