Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3be22b9

Browse filesBrowse files
authored
Merge pull request GoogleCloudPlatform#377 from GoogleCloudPlatform/tswast-bigtable
Close HappyBase connection in bigtable/hello sample.
2 parents 0976714 + d9f544a commit 3be22b9
Copy full SHA for 3be22b9

File tree

Expand file treeCollapse file tree

1 file changed

+6
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-6
lines changed

‎bigtable/hello/main.py

Copy file name to clipboardExpand all lines: bigtable/hello/main.py
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,11 @@ def main(project_id, cluster_id, zone, table_name):
3737
# The client must be created with admin=True because it will create a
3838
# table.
3939
client = bigtable.Client(project=project_id, admin=True)
40+
cluster = client.cluster(zone, cluster_id)
41+
connection = happybase.Connection(cluster=cluster)
42+
# [END connecting_to_bigtable]
4043

41-
with client:
42-
cluster = client.cluster(zone, cluster_id)
43-
cluster.reload()
44-
connection = happybase.Connection(cluster=cluster)
45-
# [END connecting_to_bigtable]
46-
44+
try:
4745
# [START creating_a_table]
4846
print('Creating the {} table.'.format(table_name))
4947
column_family_name = 'cf1'
@@ -95,6 +93,8 @@ def main(project_id, cluster_id, zone, table_name):
9593
print('Deleting the {} table.'.format(table_name))
9694
connection.delete_table(table_name)
9795
# [END deleting_a_table]
96+
finally:
97+
connection.close()
9898

9999

100100
if __name__ == '__main__':

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.