我不知道爲什麼,但counter_inc
方法不工作,沒有模擬器,指向一個開發真實的實例。Bigtable Google Happybase Python KeyError試圖做`counter_inc`
段:
from google.cloud import bigtable
from google.cloud import happybase
client = bigtable.Client(project='robbie-ai', admin=True)
instance = client.instance('visio-bt-staging')
connection = happybase.Connection(instance=instance)
connection.create_table('commons_TestBTModelsTable', {'family': None, 'counters': None})
table = connection.table('commons_TestBTModelsTable')
table.put('row-key1', {'family:surname': 'Trump'})
print("Getting row 'row-key1': {}".format(table.row(b'row-key1')))
table.counter_inc(b'row1', b'counters:qual1')
如果我做table.counter_inc(b'row1', 'counters:qual1')
是完全一樣的。
當作爲腳本執行:
[email protected]:/app# python scripts/counters.py
Getting row 'row-key1': {b'family:surname': b'Trump'}
Traceback (most recent call last):
File "scripts/counters.py", line 28, in <module>
table.counter_inc(b'row1', b'counters:qual1')
File "/usr/local/lib/python3.5/dist-packages/google/cloud/happybase/table.py", line 591, in counter_inc
column_cells = modified_cells[column_family_id][column_qualifier]
KeyError: 'qual1'
它是一個bug或者這個片段有問題?