Hive - python connection error
<p><strong>Here is code :</strong></p>

<pre><code>#!/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)   
</code></pre>

<p><strong>Error!</strong></p>

<blockquote>
  <p>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/<strong>init</strong>.py", line 7, in
  connect
      return Connection(*args, **kwargs)   File "/usr/lib/python2.6/site-packages/pyhs2/connections.py", line 46, in
  <strong>init</strong>
      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</p>
</blockquote>