in python/rest/rest_client.py [0:0]
def put_row(self, row_key, column, value):
""" Puts a value into an HBase cell via REST
This puts a value in the fully qualified column name. This assumes
that the table has already been created with the column family in its
schema. If it doesn't exist, you can use create_table() to doso.
:param row_key: The row we want to put a value into.
:param column: The fully qualified column (e.g.
my_column_family:content)
:param value: A string representing the sequence of bytes we want to
put into the cell
:return: None
"""
row_key_encoded = base64.b64encode(row_key)
column_encoded = base64.b64encode(column)
value_encoded = base64.b64encode(value)
cell = OrderedDict([
("key", row_key_encoded),
("Cell", [{"column": column_encoded, "$": value_encoded}])
])
rows = [cell]
json_output = {"Row": rows}
r = requests.post(
self.base_url + "/" + self.table_name + "/" + row_key,
data=json.dumps(json_output),
headers={
"Content-Type": "application/json",
"Accept": "application/json",
})
if r.status_code != 200:
print "got status code %d when putting" % r.status_code