简体   繁体   English

无法在Python中使用Happybase创建简单表

[英]Cannot create simple table using Happybase in Python

I am trying to create a table using Happybase. 我正在尝试使用Happybase创建表。 To start I enter the following commands get Hbase and Thrift running: 首先,我输入以下命令以运行Hbase和Thrift:

start-hbase.sh
hbase thrift start &

Once this is running I open Python's command prompt and type the following: 运行该命令后,我将打开Python的命令提示符并键入以下内容:

import happybase as hb
connection = hb.Connection()
connection.open()

However when I try to create a table: 但是,当我尝试创建表时:

connection.create_table(
'mytable',
{'cf1': dict(max_versions=10),
 'cf2': dict(max_versions=1, block_cache_enabled=False),
 'cf3': dict(),  # use defaults
}

I get the following error that I just don't understand. 我收到以下我不明白的错误。

Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
  File "/usr/local/lib/python2.7/dist-packages/happybase/connection.py", line 309, in create_table
    self.client.createTable(name, column_descriptors)
  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 429, in cybin.TCyBinaryProtocol.read_message_begin (thriftpy/protocol/cybin/cybin.c:6325)
  File "thriftpy/protocol/cybin/cybin.pyx", line 60, in cybin.read_i32 (thriftpy/protocol/cybin/cybin.c:1546)
  File "thriftpy/transport/buffered/cybuffered.pyx", line 65, in thriftpy.transport.buffered.cybuffered.TCyBufferedTransport.c_read (thriftpy/transport/buffered/cybuffered.c:1881)
  File "thriftpy/transport/buffered/cybuffered.pyx", line 69, in thriftpy.transport.buffered.cybuffered.TCyBufferedTransport.read_trans (thriftpy/transport/buffered/cybuffered.c:1948)
  File "thriftpy/transport/cybase.pyx", line 61, in thriftpy.transport.cybase.TCyBuffer.read_trans (thriftpy/transport/cybase.c:1472)
  File "/usr/local/lib/python2.7/dist-packages/thriftpy/transport/socket.py", line 125, in read
    message='TSocket read 0 bytes')
thriftpy.transport.TTransportException: TTransportException(message='TSocket read 0 bytes', type=4)
)

You need to specify the server address, and possibly port: 您需要指定服务器地址,可能还需要指定端口:

connection = hb.Connection(SERVER, PORT)

You can probably omit the port value, as most likely the default value will match, but just in case check on what port your thrift server is listening and specify that as a numeric value 您可能会省略端口值,因为默认值很可能会匹配,但是以防万一检查您的二手服务器正在监听哪个端口并将其指定为数字值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM