This is the code I am using
NPS Data
with pyhs2.connect(host='localhost',authMechanism = "PLAIN", port = 10000, user='kumara',database='project_krypton') as connection:
with connection.cursor() as cursor:
print "Connection Established..."
print "Reading Data..."
print "-"_50
cursor.execute("SELECT * FROM nps")
schema = cursor.getSchema()
print schema
cols = [s['columnName'] for s in schema]
print "\n\nColumns Importing: ", cols
nps = pd.DataFrame(data=cursor.fetchall(), columns=cols)
print "Data import complete!"
print "-"_50
print "\n\nDimensions of Imported data: ", all_data.shape
print "\nSnapshot of data: \n\n", all_data.head()
all_data.to_csv('all_data_export.csv')
I am getting this error. Can you help please ?
TTransportException Traceback (most recent call last)
in ()
1 # NPS Data
----> 2 with pyhs2.connect(host='localhost',authMechanism = "PLAIN", port = 10000, user='kumara',database='project_krypton') as connection:
3 with connection.cursor() as cursor:
4 print "Connection Established..."
5 print "Reading Data..."
/Users/kumara/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pyhs2/init.pyc in connect(_args, *_kwargs)
5 """
6 from .connections import Connection
----> 7 return Connection(_args, *_kwargs)
/Users/kumara/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pyhs2/connections.pyc in init(self, host, port, authMechanism, user, password, database, configuration, timeout)
44
45 self.client = TCLIService.Client(TBinaryProtocol(transport))
---> 46 transport.open()
47 res = self.client.OpenSession(TOpenSessionReq(username=user, password=password, configuration=configuration))
48 self.session = res.sessionHandle
/Users/kumara/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pyhs2/cloudera/thrift_sasl.pyc in open(self)
72 # SASL negotiation loop
73 while True:
---> 74 status, payload = self._recv_sasl_message()
75 if status not in (self.OK, self.COMPLETE):
76 raise TTransportException(type=TTransportException.NOT_OPEN,
/Users/kumara/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pyhs2/cloudera/thrift_sasl.pyc in _recv_sasl_message(self)
90
91 def _recv_sasl_message(self):
---> 92 header = self._trans.readAll(5)
93 status, length = struct.unpack(">BI", header)
94 if length > 0:
/Users/kumara/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/thrift/transport/TTransport.pyc in readAll(self, sz)
56 have = 0
57 while (have < sz):
---> 58 chunk = self.read(sz - have)
59 have += len(chunk)
60 buff += chunk
/Users/kumara/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/thrift/transport/TSocket.pyc in read(self, sz)
118 if len(buff) == 0:
119 raise TTransportException(type=TTransportException.END_OF_FILE,
--> 120 message='TSocket read 0 bytes')
121 return buff
122
TTransportException: TSocket read 0 bytes
This is the code I am using
I am getting this error. Can you help please ?