如何使用 Python 连接到 GCP BigTable
How to connect to GCP BigTable using Python
在我的环境变量中设置“GOOGLE_APPLICATION_CREDENTIALS”后,我正在使用 python(google-cloud-bigtable 库)连接到我的 GCP BigTable 实例。我成功了。
但是,我的要求是我想在创建 BigTable 客户端对象时在 运行 期间传递 凭据,如下所示:
client = bigtable.Client(credentials='82309281204023049', project='xjkejfkx')
我已按照 GCP BigTable Client Documentation 连接到 GCP BigTable,但出现此错误:
Traceback (most recent call last):
File "D:/testingonlyinformix/bigtable.py", line 14, in <module>
client = bigtable.Client(credentials="9876543467898765", project="xjksjkdn", admin=True)
File "D:\testingonlyinformix\new_venv\lib\site-packages\google\cloud\bigtable\client.py", line 196, in __init__
project=project, credentials=credentials, client_options=client_options,
File "D:\testingonlyinformix\new_venv\lib\site-packages\google\cloud\client\__init__.py", line 320, in __init__
self, credentials=credentials, client_options=client_options, _http=_http
File "D:\testingonlyinformix\new_venv\lib\site-packages\google\cloud\client\__init__.py", line 167, in __init__
raise ValueError(_GOOGLE_AUTH_CREDENTIALS_HELP)
ValueError: This library only supports credentials from google-auth-library-python. See https://google-auth.readthedocs.io/en/latest/ for help on authentication with this library.
有人可以建议 fields/attributes 一个 Client
对象在建立连接的 运行 时间内期望的所有内容吗到 GCP BigTable?
谢谢
经过 2 小时的搜索,我终于找到了这些页面,请按顺序查看它们:
from google_auth_oauthlib import flow
appflow = flow.InstalledAppFlow.from_client_secrets_file(
"client_secrets.json", scopes=["https://www.googleapis.com/auth/bigtable.admin"])
appflow.run_console()
credentials = appflow.credentials
上一步中的credentials
需要提供给BigTableclient对象:
client = bigtable.Client(credentials=credentials, project='xjkejfkx')
这个解决方案对我有用,如果有人有任何其他建议,请pitch-in。
在我的环境变量中设置“GOOGLE_APPLICATION_CREDENTIALS”后,我正在使用 python(google-cloud-bigtable 库)连接到我的 GCP BigTable 实例。我成功了。
但是,我的要求是我想在创建 BigTable 客户端对象时在 运行 期间传递 凭据,如下所示:
client = bigtable.Client(credentials='82309281204023049', project='xjkejfkx')
我已按照 GCP BigTable Client Documentation 连接到 GCP BigTable,但出现此错误:
Traceback (most recent call last):
File "D:/testingonlyinformix/bigtable.py", line 14, in <module>
client = bigtable.Client(credentials="9876543467898765", project="xjksjkdn", admin=True)
File "D:\testingonlyinformix\new_venv\lib\site-packages\google\cloud\bigtable\client.py", line 196, in __init__
project=project, credentials=credentials, client_options=client_options,
File "D:\testingonlyinformix\new_venv\lib\site-packages\google\cloud\client\__init__.py", line 320, in __init__
self, credentials=credentials, client_options=client_options, _http=_http
File "D:\testingonlyinformix\new_venv\lib\site-packages\google\cloud\client\__init__.py", line 167, in __init__
raise ValueError(_GOOGLE_AUTH_CREDENTIALS_HELP)
ValueError: This library only supports credentials from google-auth-library-python. See https://google-auth.readthedocs.io/en/latest/ for help on authentication with this library.
有人可以建议 fields/attributes 一个 Client
对象在建立连接的 运行 时间内期望的所有内容吗到 GCP BigTable?
谢谢
经过 2 小时的搜索,我终于找到了这些页面,请按顺序查看它们:
from google_auth_oauthlib import flow
appflow = flow.InstalledAppFlow.from_client_secrets_file(
"client_secrets.json", scopes=["https://www.googleapis.com/auth/bigtable.admin"])
appflow.run_console()
credentials = appflow.credentials
上一步中的credentials
需要提供给BigTableclient对象:
client = bigtable.Client(credentials=credentials, project='xjkejfkx')
这个解决方案对我有用,如果有人有任何其他建议,请pitch-in。