1- # Cloud Bigtable Hello World ( HappyBase)
1+ # Cloud Bigtable Hello World via the HappyBase API
22
33This is a simple application that demonstrates using the [ Google Cloud Client
4- Library] [ gcloud-python ] to connect to and interact with Cloud Bigtable.
4+ Library HappyBase package] [ gcloud-python-happybase ] , an implementation of the [ HappyBase
5+ API] [ happybase ] to connect to and interact with Cloud Bigtable.
56
6- [ gcloud-python ] : https://github.com/GoogleCloudPlatform/gcloud-python
7+ <!-- auto-doc-link -->
8+ These samples are used on the following documentation page:
79
10+ > https://cloud.google.com/bigtable/docs/samples-python-hello-happybase
811
9- ## Provision a cluster
12+ <!-- end-auto-doc-link -->
1013
11- Follow the instructions in the [ user documentation ] ( https://cloud.google.com/bigtable/docs/creating-cluster )
12- to create a Google Cloud Platform project and Cloud Bigtable cluster if necessary.
13- You'll need to reference your project ID, zone and cluster ID to run the application.
14+ [ gcloud-python-happybase ] : https://googlecloudplatform.github.io/gcloud-python/stable/happybase-package.html
15+ [ happybase ] : http://happybase.readthedocs.io/en/stable/
16+ [ sample-docs ] : https://cloud.google.com/bigtable/docs/samples-python-hello-happybase
1417
1518
16- ## Run the application
19+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
20+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
21+ ** Table of Contents**
22+
23+ - [ Downloading the sample] ( #downloading-the-sample )
24+ - [ Costs] ( #costs )
25+ - [ Provisioning an instance] ( #provisioning-an-instance )
26+ - [ Running the application] ( #running-the-application )
27+ - [ Cleaning up] ( #cleaning-up )
28+
29+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
30+
31+
32+ ## Downloading the sample
33+
34+ Download the sample app and navigate into the app directory:
35+
36+ 1 . Clone the [ Python samples
37+ repository] ( https://github.com/GoogleCloudPlatform/python-docs-samples ) , to
38+ your local machine:
39+
40+ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
41+
42+ Alternatively, you can [ download the
43+ sample] ( https://github.com/GoogleCloudPlatform/python-docs-samples/archive/master.zip )
44+ as a zip file and extract it.
45+
46+ 2 . Change to the sample directory.
47+
48+ cd python-docs-samples/bigtable/hello_happybase
49+
50+
51+ ## Costs
52+
53+ This sample uses billable components of Cloud Platform, including:
54+
55+ + Google Cloud Bigtable
56+
57+ Use the [ Pricing Calculator] [ bigtable-pricing ] to generate a cost estimate
58+ based on your projected usage. New Cloud Platform users might be eligible for
59+ a [ free trial] [ free-trial ] .
60+
61+ [ bigtable-pricing ] : https://cloud.google.com/products/calculator/#id=1eb47664-13a2-4be1-9d16-6722902a7572
62+ [ free-trial ] : https://cloud.google.com/free-trial
63+
64+
65+ ## Provisioning an instance
66+
67+ Follow the instructions in the [ user
68+ documentation] ( https://cloud.google.com/bigtable/docs/creating-instance ) to
69+ create a Google Cloud Platform project and Cloud Bigtable instance if necessary.
70+ You'll need to reference your project id and instance id to run the
71+ application.
72+
73+
74+ ## Running the application
1775
1876First, set your [ Google Application Default Credentials] ( https://developers.google.com/identity/protocols/application-default-credentials )
1977
@@ -23,45 +81,29 @@ Install the dependencies with pip.
2381$ pip install -r requirements.txt
2482```
2583
26- Run the application. Replace the command-line parameters with values for your cluster .
84+ Run the application. Replace the command-line parameters with values for your instance .
2785
2886```
29- $ python main.py my-project my-cluster us-central1-c
87+ $ python main.py my-project my-instance
3088```
3189
3290You will see output resembling the following:
3391
3492```
35- Create table Hello-Bigtable-1234
93+ Create table Hello-Bigtable
3694Write some greetings to the table
3795Scan for all greetings:
3896 greeting0: Hello World!
3997 greeting1: Hello Cloud Bigtable!
4098 greeting2: Hello HappyBase!
41- Delete table Hello-Bigtable-1234
99+ Delete table Hello-Bigtable
42100```
43101
44- ## Understanding the code
45-
46- The [ application] ( main.py ) uses the [ Google Cloud Bigtable HappyBase
47- package] [ Bigtable HappyBase ] , an implementation of the [ HappyBase] [ HappyBase ]
48- library, to make calls to Cloud Bigtable. It demonstrates several basic
49- concepts of working with Cloud Bigtable via this API:
50-
51- [ Bigtable HappyBase ] : https://googlecloudplatform.github.io/gcloud-python/stable/happybase-package.html
52- [ HappyBase ] : http://happybase.readthedocs.io/en/latest/index.html
53102
54- - Creating a [ Connection] [ HappyBase Connection ] to a Cloud Bigtable
55- [ Cluster] [ Cluster API ] .
56- - Using the [ Connection] [ HappyBase Connection ] interface to create, disable and
57- delete a [ Table] [ HappyBase Table ] .
58- - Using the Connection to get a Table.
59- - Using the Table to write rows via a [ put] [ HappyBase Table Put ] and scan
60- across multiple rows using [ scan] [ HappyBase Table Scan ] .
103+ ## Cleaning up
61104
62- [ Cluster API ] : https://googlecloudplatform.github.io/gcloud-python/stable/bigtable-cluster.html
63- [ HappyBase Connection ] : https://googlecloudplatform.github.io/gcloud-python/stable/happybase-connection.html
64- [ HappyBase Table ] : https://googlecloudplatform.github.io/gcloud-python/stable/happybase-table.html
65- [ HappyBase Table Put ] : https://googlecloudplatform.github.io/gcloud-python/stable/happybase-table.html#gcloud.bigtable.happybase.table.Table.put
66- [ HappyBase Table Scan ] : https://googlecloudplatform.github.io/gcloud-python/stable/happybase-table.html#gcloud.bigtable.happybase.table.Table.scan
105+ To avoid incurring extra charges to your Google Cloud Platform account, remove
106+ the resources created for this sample.
67107
108+ - [ Delete the Cloud Bigtable
109+ instance] ( https://cloud.google.com/bigtable/docs/deleting-instance ) .
0 commit comments