Skip to content

Commit 27d6927

Browse files
AVaksmanbillyjacobson
authored andcommitted
Bigtable: add filter region tag to hello world [(#1878)](GoogleCloudPlatform/python-docs-samples#1878)
* use row.cell rather than row.cell_value in the example add 'filter' and 'dependencies' region tags * move the comment line
1 parent 400261e commit 27d6927

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

samples/hello/main.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
"""
2626

2727
import argparse
28+
# [START dependencies]
2829
import datetime
2930

3031
from google.cloud import bigtable
3132
from google.cloud.bigtable import column_family
3233
from google.cloud.bigtable import row_filters
34+
# [END dependencies]
3335

3436

3537
def main(project_id, instance_id, table_id):
@@ -82,14 +84,19 @@ def main(project_id, instance_id, table_id):
8284
table.mutate_rows(rows)
8385
# [END writing_rows]
8486

87+
# [START creating_a_filter]
88+
# Create a filter to only retrieve the most recent version of the cell
89+
# for each column accross entire row.
90+
row_filter = row_filters.CellsColumnLimitFilter(1)
91+
# [END creating_a_filter]
92+
8593
# [START getting_a_row]
8694
print('Getting a single greeting by row key.')
8795
key = 'greeting0'.encode()
8896

89-
# Only retrieve the most recent version of the cell.
90-
row_filter = row_filters.CellsColumnLimitFilter(1)
9197
row = table.read_row(key, row_filter)
92-
print(row.cell_value(column_family_id, column))
98+
cell = row.cells[column_family_id][column][0]
99+
print(cell.value.decode('utf-8'))
93100
# [END getting_a_row]
94101

95102
# [START scanning_all_rows]

0 commit comments

Comments
 (0)