Support Questions
Find answers, ask questions, and share your expertise
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Connecting hive using Python Embedded Mode


Connecting hive using Python Embedded Mode

Rising Star

I'm trying to connect Hive to fetch some tables using pyhs2 in Embedded/Pseudo Mode. I have kept all the properties in pyhs2.connect same except port number which i got from the reference site mentioned here

#!/usr/bin/env python
import pyhs2
with pyhs2.connect(host='localhost',port=50070,authMechanism="PLAIN", user='root',password='test',database='default') as conn:
    with conn.cursor() as cur:         #Show databases
        print cur.getDatabases() #Execute query
        cur.execute("select * from analytical")#Return column info from query
        print cur.getSchema()
        #Fetch table results
        for i in cur.fetch():             print i

Finally when i execute it it show me the below ouput and not able to read anything. It was in embedded mode so havn't put the port as 10000 Here. Can someone help me getting this problem solved.

vaibhav@vaibhav-Lenovo-G570:/home/hduser$ ./
Traceback(most recent call last):File"./", line 4,in<module>with pyhs2.connect(host='localhost',port=50070,authMechanism="PLAIN", user='root',password='test',database='default')as conn:File"/home/vaibhav/.local/lib/python2.7/site-packages/pyhs2/", line 7,in connect
    returnConnection(*args,**kwargs)File"/home/vaibhav/.local/lib/python2.7/site-packages/pyhs2/", line 46,in __init__"/home/vaibhav/.local/lib/python2.7/site-packages/pyhs2/cloudera/", line 74,in open
    status, payload = self._recv_sasl_message()File"/home/vaibhav/.local/lib/python2.7/site-packages/pyhs2/cloudera/", line 95,in _recv_sasl_message
    payload = self._trans.readAll(length)File"/home/vaibhav/.local/lib/python2.7/site-packages/thrift/transport/", line 60,in readAll
    chunk = - have)File"/home/vaibhav/.local/lib/python2.7/site-packages/thrift/transport/", line 132,in read
    message='TSocket read 0 bytes')
thrift.transport.TTransport.TTransportException:TSocket read 0 bytes
Don't have an account?
Coming from Hortonworks? Activate your account here