hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karimkhan Pathan <karimkhan...@gmail.com>
Subject Fwd: Using python for hive table quering gives error
Date Fri, 15 Jan 2016 09:58:51 GMT
I am trying to query hive table with basic example code:

*import pyhs2*

*with pyhs2.connect(host='dmet-master05.inetu.net
<http://dmet-master05.inetu.net>',*
*                   port=10000,*
*                   authMechanism='PLAIN',*
*                   user='karim',*
*                   password='karim',*
*                   database='default') as conn:*
*    with conn.cursor() as cur:*
*        #Show databases*
*        print cur.getDatabases()*

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

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

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

When I execute this script, it gives


*Traceback (most recent call last):*
*  File "py_hive.py", line 8, in <module>*
*    database='default') as conn:*
*  File
"/home/karimk/python/lib/python2.7/site-packages/pyhs2/__init__.py", line
7, in connect*
*    return Connection(*args, **kwargs)*
*  File
"/home/karimk/python/lib/python2.7/site-packages/pyhs2/connections.py",
line 52, in __init__*
*    cur.execute(query) *
*  File "/home/karimk/python/lib/python2.7/site-packages/pyhs2/cursor.py",
line 61, in execute*
*    res = self.client.ExecuteStatement(query)*
*  File
"/home/karimk/python/lib/python2.7/site-packages/pyhs2/TCLIService/TCLIService.py",
line 244, in ExecuteStatement*
*    return self.recv_ExecuteStatement()*
*  File
"/home/karimk/python/lib/python2.7/site-packages/pyhs2/TCLIService/TCLIService.py",
line 260, in recv_ExecuteStatement*
*    raise x*
*thrift.Thrift.TApplicationException: Required field 'sessionHandle' is
unset! Struct:TExecuteStatementReq(sessionHandle:null, statement:USE
default, confOverlay:{})*


Any help much appreciated.



-- 
Regards,
Karimkhan,
http://www.quora.com/Pathan-Karimkhan
https://www.facebook.com/karimkhan.it
http://in.linkedin.com/in/karimkhanp

Mime
View raw message