Error connecting hive using python pyhs2

0 votes

I am trying to access hive using pyhs2. I tried the following code:

example.py

import pyhs2
conn = pyhs2.connect(host='localhost', port=10000, user=None, password=None,database='default')
with conn.cursor() as new_cur:
        new_cur.execute("select * from table")
        for i in new_cur.fetch():
            print i

I am getting the following error:

    Traceback (most recent call last):
 File "example.py", line 2, in <module> conn = pyhs2.connect(host='localhost', port=10000,user=None, password=None,database='default')
      
    thrift.transport.TTransport.TTransportException: Could not connect to localhost:10000
Jan 11 in Big Data Hadoop by slayer
• 29,050 points
108 views

1 answer to this question.

0 votes

Seems like the host IP is not right. Find out the right IP address. If you are using Linux then you can use the following command to get the host IP address

hostname -I

After this, replace the right IP address in the code and it should work.

answered Jan 11 by Omkar
• 67,120 points

Related Questions In Big Data Hadoop

0 votes
0 answers

Error running hadoop mapreduce in Python using Hadoop Streaming

I was trying a sample mapredyce code ...READ MORE

Apr 2, 2018 in Big Data Hadoop by nitinrawat895
• 10,110 points
77 views
+3 votes
1 answer

Getting Connection Error while loading data into table using cloudera hive

Hey Nafeesa, Itseems that Hive is not able ...READ MORE

answered Oct 3, 2018 in Big Data Hadoop by Vardhan
• 11,490 points
55 views
0 votes
1 answer

Getting error while building Hadoop core jar using ant.

I think you are missing libtool library. ...READ MORE

answered Apr 18, 2018 in Big Data Hadoop by coldcode
• 2,010 points
42 views
0 votes
1 answer

Setting Hive/Hadoop property using Hive Query

You can set Hadoop & Hive conf ...READ MORE

answered Apr 18, 2018 in Big Data Hadoop by Shubham
• 13,190 points
136 views
0 votes
1 answer

Connect to Hive using Pyhive

Here's how we can connect to Hive ...READ MORE

answered Jan 8 in Big Data Hadoop by Omkar
• 67,120 points
557 views
0 votes
0 answers

try except is not working while using hdfs command

Hi,  I am trying to run following things ...READ MORE

Mar 6 in Python by anonymous
28 views
0 votes
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,110 points
2,054 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,110 points
197 views
0 votes
1 answer

Error while connecting to Hive using Java JDBC

Use ​org.apache.hive.jdbc.HiveDriver as your driver. It ...READ MORE

answered Nov 21, 2018 in Big Data Hadoop by Omkar
• 67,120 points
57 views
0 votes
1 answer

How to Access Hive via Python?

The easiest way is to use PyHive. To ...READ MORE

answered Oct 9, 2018 in Big Data Hadoop by Omkar
• 67,120 points
1,885 views