[英]Google Cloud Datastore Query's
Trying to locate data based on its Name/ID field which is auto generated within Google cloud.尝试根据在 Google 云中自动生成的名称/ID 字段来定位数据。 I want to be able to update the given entity, however I am finding it hard to work with the data formatting.
我希望能够更新给定的实体,但是我发现很难使用数据格式。 I have a list of data with a button which says 'Update" when clicking the update it gives the Unique Name/ID of that entity, however i cannot seem to find a method of also pulling the information associated with that Name/ID within google cloud.
我有一个带有“更新”按钮的数据列表,当单击更新时它会给出该实体的唯一名称/ID,但是我似乎无法找到一种方法来在谷歌中提取与该名称/ID 关联的信息云。
Data inside google cloud谷歌云内的数据
Unique ID located but struggling to pull the other data based on that ID已找到唯一 ID,但难以根据该 ID 提取其他数据
def updateSong():
songID = request.form['Update']
# songQuery = datastore_client.query(kind="Song")
# songs = list(songQuery.fetch())
query = datastore_client.query(kind='Song', ancestor=songID)
songData = query.fetch()
print(songData)
id_token = request.cookies.get("token")
error_message = None
if id_token:
try:
user_data = google.oauth2.id_token.verify_firebase_token(
id_token, firebase_request_adapter)
except ValueError as exc:
error_message = str(exc)
return render_template('UpdateSong.html', user_data=user_data, error_message=error_message, songID=songID)
Is there not a method of querying the song ID to then be able to use it as such:是否没有一种方法可以查询歌曲 ID 以便能够像这样使用它:
song['Title'] = song title
Try this尝试这个
query = datastore_client.query()
query.key_filter(datastore_client.key('Song', songID))
song = list(query.fetch())
Source: https://googleapis.dev/python/datastore/latest/_modules/google/cloud/datastore/query.html#Query.key_filter来源: https://googleapis.dev/python/datastore/latest/_modules/google/cloud/datastore/query.html#Query.key_filter
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.