gpt4 book ai didi

python - hive -python连接错误

转载 作者:行者123 更新时间:2023-12-02 21:11:44 25 4
gpt4 key购买 nike

这是代码:

#!/usr/bin/env python
import pyhs2
try:
with pyhs2.connect(host='localhost',
port=10001,
authMechanism="PLAIN",
user='root',
password='test',
database='test') as conn:
with conn.cursor() as cur:
#Show databases
print cur.getDatabases()

#Execute query
cur.execute("select * from raw_stats")

#Return column info from query
print cur.getSchema()

#Fetch table results
for i in cur.fetch():
print i

except Thrift.TException, tx:
print '%s' % (tx.message)

错误!

Traceback (most recent call last): File "/usr/local/py/test.py", line 8, in database='default') as conn: File "/usr/lib/python2.6/site-packages/pyhs2/init.py", line 7, in connect return Connection(*args, **kwargs) File "/usr/lib/python2.6/site-packages/pyhs2/connections.py", line 46, in init transport.open() File "/usr/lib/python2.6/site-packages/pyhs2/cloudera/thrift_sasl.py", line 55, in open self._trans.open() File "/usr/lib64/python2.6/site-packages/thrift/transport/TSocket.py", line 101, in open message=message) thrift.transport.TTransport.TTransportException: Could not connect to localhost:10001

最佳答案

通过启动hiveServer2服务并更改端口10000来解决。

关于python - hive -python连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40088937/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com