Skip to content

Commit e657b04

Browse files
Cloud Bigtable Region tag consistency [(#2018)](GoogleCloudPlatform/python-docs-samples#2018)
* Updating the region tags to be consistent across Cloud Bigtable. Need to figure out filtering for happybase or rename * Remove happybase filter * Linting
1 parent 4dd74a5 commit e657b04

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

samples/hello_happybase/main.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,33 @@
2525
"""
2626

2727
import argparse
28-
28+
# [START bigtable_hw_imports_happybase]
2929
from google.cloud import bigtable
3030
from google.cloud import happybase
31+
# [END bigtable_hw_imports_happybase]
3132

3233

3334
def main(project_id, instance_id, table_name):
34-
# [START connecting_to_bigtable]
35+
# [START bigtable_hw_connect_happybase]
3536
# The client must be created with admin=True because it will create a
3637
# table.
3738
client = bigtable.Client(project=project_id, admin=True)
3839
instance = client.instance(instance_id)
3940
connection = happybase.Connection(instance=instance)
40-
# [END connecting_to_bigtable]
41+
# [END bigtable_hw_connect_happybase]
4142

4243
try:
43-
# [START creating_a_table]
44+
# [START bigtable_hw_create_table_happybase]
4445
print('Creating the {} table.'.format(table_name))
4546
column_family_name = 'cf1'
4647
connection.create_table(
4748
table_name,
4849
{
4950
column_family_name: dict() # Use default options.
5051
})
51-
# [END creating_a_table]
52+
# [END bigtable_hw_create_table_happybase]
5253

53-
# [START writing_rows]
54+
# [START bigtable_hw_write_rows_happybase]
5455
print('Writing some greetings to the table.')
5556
table = connection.table(table_name)
5657
column_name = '{fam}:greeting'.format(fam=column_family_name)
@@ -75,26 +76,26 @@ def main(project_id, instance_id, table_name):
7576
table.put(
7677
row_key, {column_name.encode('utf-8'): value.encode('utf-8')}
7778
)
78-
# [END writing_rows]
79+
# [END bigtable_hw_write_rows_happybase]
7980

80-
# [START getting_a_row]
81+
# [START bigtable_hw_get_by_key_happybase]
8182
print('Getting a single greeting by row key.')
8283
key = 'greeting0'.encode('utf-8')
8384
row = table.row(key)
8485
print('\t{}: {}'.format(key, row[column_name.encode('utf-8')]))
85-
# [END getting_a_row]
86+
# [END bigtable_hw_get_by_key_happybase]
8687

87-
# [START scanning_all_rows]
88+
# [START bigtable_hw_scan_all_happybase]
8889
print('Scanning for all greetings:')
8990

9091
for key, row in table.scan():
9192
print('\t{}: {}'.format(key, row[column_name.encode('utf-8')]))
92-
# [END scanning_all_rows]
93+
# [END bigtable_hw_scan_all_happybase]
9394

94-
# [START deleting_a_table]
95+
# [START bigtable_hw_delete_table_happybase]
9596
print('Deleting the {} table.'.format(table_name))
9697
connection.delete_table(table_name)
97-
# [END deleting_a_table]
98+
# [END bigtable_hw_delete_table_happybase]
9899

99100
finally:
100101
connection.close()

0 commit comments

Comments
 (0)