【发布时间】:2021-11-29 12:59:05
【问题描述】:
我正在使用 Google App Engine 和 Datastore。
这是我的模型类project_name/model/quiz_models.py
from google.appengine.ext import db
class Quiz(db.Model):
quiz_id = db.StringProperty()
post_id = db.StringProperty()
creator_id = db.StringProperty()
timestamp = db.DateTimeProperty()
quiz_title = db.StringProperty()
main.py文件
@app.route('/insert_db')
def run_quickstart():
quiz = Quiz(post_id=data['post_id'],
quiz_id='123',
quiz_info='test info',
creator_id=data['creator_id'],
timestamp=datetime.datetime.now(),
quiz_title='Test title')
quiz.put()
我何时向/insert_db URL 发出获取请求时收到此错误
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/google/appengine/api/apiproxy_stub_map.py", line 69, in CreateRPC
assert stub, 'No api proxy found for service "%s"' % service AssertionError: No api proxy found for service "datastore_v3"
但是 google 提供的这个示例 sn-ps 工作正常
@app.route('/insert_db')
def run_quickstart():
# [START datastore_quickstart]
# Imports the Google Cloud client library
# Instantiates a client
datastore_client = datastore.Client()
# The kind for the new entity
kind = "Tasker"
# The name/ID for the new entity
name = "sampletask1aa"
# The Cloud Datastore key for the new entity
task_key = datastore_client.key(kind, name)
# Prepares the new entity
task = datastore.Entity(key=task_key)
task.update(
{
"category": "Personal",
"done": False,
"priority": 4,
"description": "Cloud Datastore",
}
)
# Saves the entity
datastore_client.put(task)
【问题讨论】:
标签: google-app-engine google-cloud-platform google-cloud-datastore google-app-engine-python