1

I am trying to connect to hbase-1.2.6 from python code, is as:

import happybase
connection = happybase.Connection(host='localhost',port=16010)
table = connection.table('blogpost')
table.put('1', {'post:title': 'hello world1'})

I manually created the table-"blogpost" in hbase. I am using python-2.7 and happybase-1.1.0.

error log are as:

/usr/bin/python2.7 /home/spark/PycharmProjects/PySpark/hbase.py Traceback (most recent call last):

File "/home/spark/PycharmProjects/PySpark/hbase.py", line 5, in <module>
table.put('1', {'post:title': 'hello world1'})

File "/usr/local/lib/python2.7/dist-packages/happybase/table.py", line 464, in put
batch.put(row, data)

File "/usr/local/lib/python2.7/dist-packages/happybase/batch.py", line 137, in __exit__
self.send()

File "/usr/local/lib/python2.7/dist-packages/happybase/batch.py", line 60, in send
self._table.connection.client.mutateRows(self._table.name, bms, {})

File "/usr/local/lib/python2.7/dist-packages/thriftpy/thrift.py", line 198, in _req
return self._recv(_api)

File "/usr/local/lib/python2.7/dist-packages/thriftpy/thrift.py", line 210, in _recv
fname, mtype, rseqid = self._iprot.read_message_begin()

File "thriftpy/protocol/cybin/cybin.pyx", line 439, in cybin.TCyBinaryProtocol.read_message_begin (thriftpy/protocol/cybin/cybin.c:6470) cybin.ProtocolError: No protocol version header

thanks. Process finished with exit code 1

andy
  • 525
  • 3
  • 6
  • 22
  • start thrift through hbase thrift start and then the following codes are OK. import happybase connection = happybase.Connection('localhost') – andy Oct 13 '17 at 05:27
  • 1
    Happybase connects to HBase through the Thrift API. you have to start it first before attempting to connect. The default port is 9090. But you can just connect by only specifying the host name. check this https://github.com/wbolster/happybase/issues/161 – void Oct 16 '17 at 18:20

0 Answers0