|
| 1 | +.. This file is automatically generated. Do not edit this file directly. |
| 2 | +
|
| 3 | +Google Cloud Bigtable Python Samples |
| 4 | +=============================================================================== |
| 5 | + |
| 6 | +This directory contains samples for Google Cloud Bigtable. `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's the same database that powers many core Google services, including Search, Analytics, Maps, and Gmail. |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +.. _Google Cloud Bigtable: https://cloud.google.com/bigtable/docs |
| 12 | + |
| 13 | +Setup |
| 14 | +------------------------------------------------------------------------------- |
| 15 | + |
| 16 | + |
| 17 | +Authentication |
| 18 | +++++++++++++++ |
| 19 | + |
| 20 | +Authentication is typically done through `Application Default Credentials`_, |
| 21 | +which means you do not have to change the code to authenticate as long as |
| 22 | +your environment has credentials. You have a few options for setting up |
| 23 | +authentication: |
| 24 | + |
| 25 | +#. When running locally, use the `Google Cloud SDK`_ |
| 26 | + |
| 27 | + .. code-block:: bash |
| 28 | +
|
| 29 | + gcloud beta auth application-default login |
| 30 | +
|
| 31 | +
|
| 32 | +#. When running on App Engine or Compute Engine, credentials are already |
| 33 | + set-up. However, you may need to configure your Compute Engine instance |
| 34 | + with `additional scopes`_. |
| 35 | + |
| 36 | +#. You can create a `Service Account key file`_. This file can be used to |
| 37 | + authenticate to Google Cloud Platform services from any environment. To use |
| 38 | + the file, set the ``GOOGLE_APPLICATION_CREDENTIALS`` environment variable to |
| 39 | + the path to the key file, for example: |
| 40 | + |
| 41 | + .. code-block:: bash |
| 42 | +
|
| 43 | + export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json |
| 44 | +
|
| 45 | +.. _Application Default Credentials: https://cloud.google.com/docs/authentication#getting_credentials_for_server-centric_flow |
| 46 | +.. _additional scopes: https://cloud.google.com/compute/docs/authentication#using |
| 47 | +.. _Service Account key file: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount |
| 48 | + |
| 49 | +Install Dependencies |
| 50 | +++++++++++++++++++++ |
| 51 | + |
| 52 | +#. Install `pip`_ and `virtualenv`_ if you do not already have them. |
| 53 | + |
| 54 | +#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. |
| 55 | + |
| 56 | + .. code-block:: bash |
| 57 | +
|
| 58 | + $ virtualenv env |
| 59 | + $ source env/bin/activate |
| 60 | +
|
| 61 | +#. Install the dependencies needed to run the samples. |
| 62 | + |
| 63 | + .. code-block:: bash |
| 64 | +
|
| 65 | + $ pip install -r requirements.txt |
| 66 | +
|
| 67 | +.. _pip: https://pip.pypa.io/ |
| 68 | +.. _virtualenv: https://virtualenv.pypa.io/ |
| 69 | + |
| 70 | +Samples |
| 71 | +------------------------------------------------------------------------------- |
| 72 | + |
| 73 | +Basic example |
| 74 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | +To run this sample: |
| 79 | + |
| 80 | +.. code-block:: bash |
| 81 | +
|
| 82 | + $ python main.py |
| 83 | +
|
| 84 | + usage: main.py [-h] [--table TABLE] project_id instance_id |
| 85 | + |
| 86 | + Demonstrates how to connect to Cloud Bigtable and run some basic operations. |
| 87 | + Prerequisites: - Create a Cloud Bigtable cluster. |
| 88 | + https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google |
| 89 | + Application Default Credentials. |
| 90 | + https://developers.google.com/identity/protocols/application-default- |
| 91 | + credentials |
| 92 | + |
| 93 | + positional arguments: |
| 94 | + project_id Your Cloud Platform project ID. |
| 95 | + instance_id ID of the Cloud Bigtable instance to connect to. |
| 96 | + |
| 97 | + optional arguments: |
| 98 | + -h, --help show this help message and exit |
| 99 | + --table TABLE Table to create and destroy. (default: Hello-Bigtable) |
| 100 | +
|
| 101 | +
|
| 102 | +
|
| 103 | +
|
| 104 | +The client library |
| 105 | +------------------------------------------------------------------------------- |
| 106 | + |
| 107 | +This sample uses the `Google Cloud Client Library for Python`_. |
| 108 | +You can read the documentation for more details on API usage and use GitHub |
| 109 | +to `browse the source`_ and `report issues`_. |
| 110 | + |
| 111 | +.. Google Cloud Client Library for Python: |
| 112 | + https://googlecloudplatform.github.io/google-cloud-python/ |
| 113 | +.. browse the source: |
| 114 | + https://github.com/GoogleCloudPlatform/google-cloud-python |
| 115 | +.. report issues: |
| 116 | + https://github.com/GoogleCloudPlatform/google-cloud-python/issues |
| 117 | +
|
| 118 | +
|
| 119 | +.. _Google Cloud SDK: https://cloud.google.com/sdk/ |
0 commit comments