python - Google 应用引擎上的 Django : "Instance names cannot contain the ' :' character."

标签 python django google-app-engine google-cloud-sql

我正在关注this tutorial在 Google AppEngine 上运行 Django 项目。我已完成创建 Cloud SQL 实例的步骤。我正在这一步:

Now use the Cloud SDK from command line to run the following command. Copy the value shown for connectionName for the next step.

gcloud sql instances describe [YOUR_INSTANCE_NAME]

The connectionName value is in the format [PROJECT_NAME]:[REGION_NAME]:[INSTANCE_NAME].

我收到以下错误:

$ gcloud sql instances describe django-polls-184415:us-west1:polls
ERROR: (gcloud.sql.instances.describe) Instance names cannot contain the ':' character. If you meant to indicate the
project for [polls], use only 'polls' for the argument, and either add
'--project django-polls-184415:us-west1' to the command line or first run
  $ gcloud config set project django-polls-184415:us-west1

当我按照错误消息中的说明进行操作时,我得到了

$ gcloud config set project django-polls-184415:us-west1          
Updated property [core/project].
$ gcloud sql instances describe polls                             
ERROR: (gcloud.sql.instances.describe) HTTPError 403: The client is not authorized to make this request.
$ gcloud sql instances describe --project django-polls-184415:us-west1 polls-instance
ERROR: (gcloud.sql.instances.describe) HTTPError 403: The client is not authorized to make this request.

我做错了什么?更重要的是我该如何正确地做到这一点?

附录

我已使用 gcloud auth application-default login 对 Cloud SDK 进行了身份验证。验证:

$  gcloud auth list
   Credentialed Accounts
ACTIVE  ACCOUNT
*       <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b2d4ddddf2d0d3c09cd1dddf" rel="noreferrer noopener nofollow">[email protected]</a>

To set the active account, run:
    $ gcloud config set account `ACCOUNT`

(真实账户正确。我已在此处进行了编辑。)

最佳答案

你必须create the instance首先,然后才能使用它。要检查您创建的实例列表,请使用:

gcloud sql instances list

然后显示实例的信息:

gcloud beta sql instances describe [YOUR_INSTANCE_NAME]

将 [YOUR_INSTANCE_NAME] 替换为 gcloud sqlInstances list 命令的“NAME”列的结果。

就您而言,403 错误意味着您没有“轮询”实例的权限。要么是因为您不拥有该实例,要么该实例尚未创建。

关于python - Google 应用引擎上的 Django : "Instance names cannot contain the ' :' character.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47006927/

相关文章:

android - 尝试实例化 GCS 服务时出现 java.lang.NoClassDefFoundError 错误

python - 如何使用 FastAPI 从 Pydantic 模型中排除可选的未设置值?

django - 我如何告诉 grunt-usemin 忽略 Django 的静态模板标签?

python - 属性错误 : 'str' object has no attribute 'fields' Using Django non rel on GAE

python - 什么是 Python "system library"?

javascript - 为什么我的网站出现 JQuery AJAX 错误,并且没有响应 header ?

python - numpy 的就地操作(例如 `+=` )如何工作?

python - 在 Python 中读入文件并跳过文本文件的 header 部分

python - 在 Python 中验证用户输入的字符串

python - 在没有多次数据库请求的情况下在 Django 中多次调用外键对象