不了解Hbase的Python API中的行键

时间:2015-02-17 21:28:14

标签: python hbase

我有一个hbase表(customers),格式如下:

hbase(main):004:0> scan 'customers'

ROW                                                          COLUMN+CELL                                                                                                                                             
 4000001                                             column=customers_data:age, timestamp=1424123059769, value=55                                                                                            
 4000001                                             column=customers_data:firstname, timestamp=1424123059769, value=Kristina                                                                                
 4000001                                             column=customers_data:lastname, timestamp=1424123059769, value=Chung                                                                                    
 4000001                                             column=customers_data:profession, timestamp=1424123059769, value=Pilot 

我尝试使用python API http://happybase.readthedocs.org/en/latest/提取这些数据:

import happybase


connection = happybase.Connection('localhost',autoconnect=False)


connection.open()


table = connection.table('customers')


print table.families()


row = table.row('ROW')


print row 

table.families()打印为:

{'customers_data': {'block_cache_enabled': True,

  'bloom_filter_nb_hashes': 0,

  'bloom_filter_type': 'ROW',

  'bloom_filter_vector_size': 0,

  'compression': 'NONE',

  'in_memory': False,

  'max_versions': 1,

  'name': 'customers_data:',

  'time_to_live': 2147483647}}

但是它排除了{},没有任何内容。我只是对我理解hbase表中的行键值感到困惑。有任何建议如何使用python API从hbase表中获取数据?谢谢。

1 个答案:

答案 0 :(得分:1)

你的rowkey是“4000001”而不是“ROW”。