简体   繁体   English

将数据插入谷歌应用引擎数据存储

[英]inserting data into google app engine datastore

The Google_App-Engine erases everything in my table using the put statement. Google_App-Engine 使用 put 语句擦除我表中的所有内容。 I don't want it to do that, it makes for more code to have to re.put everything back in the table, every time something is added.我不希望它这样做,每次添加内容时,它都需要更多代码将所有内容重新放回表中。

Basically the issue is that the put statement erases everything.基本上问题是 put 语句删除了所有内容。 is there a way to save what I don't want to update?有没有办法保存我不想更新的内容?

here is the code: ((python web2py))这是代码:((python web2py))

biography2 = bayside(key_name='bayside', Biography=form_biography.vars.one)
biography2.put()
redirect(URL("b1", "bayside"))

the put statement, will update the biography under the table bayside, but it erases everything else in that table (genre, songs, etc...) I want it to keep the other table elements and only update the biography. put 语句将更新表 bayside 下的传记,但它会删除该表中的所有其他内容(流派、歌曲等...)我希望它保留其他表元素并仅更新传记。 Is that possible?那可能吗? Right now I have had to resort to hack that updates all table elements when I really just want to update one.现在,当我真的只想更新一个表元素时,我不得不求助于更新所有表元素。 it is very frustrating, and makes for a ton of extra code.这非常令人沮丧,并且会产生大量额外的代码。

You need to get the entity from the datastore first.您需要先从数据存储中get实体。 Then, you can modify the entity and put it back into the datastore.然后,您可以修改实体put其放回数据存储区。

to me it looks like you are overwriting an existing entity instead of getting and updating properties of an existing one.在我看来,您似乎正在覆盖现有实体,而不是获取和更新现有实体的属性。 you should take a look at the docs.你应该看看文档。 https://developers.google.com/appengine/docs/python/datastore/entities#Updating_an_Entity https://developers.google.com/appengine/docs/python/datastore/entities#Updating_an_Entity

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 保护谷歌应用引擎数据存储中的数据 - Securing data in the google app engine datastore 如何从 Google App Engine (Python) NDB/Datastore 中的子实体查询父实体? - How to query parent entity from child entity in Google App Engine (Python) NDB/Datastore? App Engine 本地数据存储区内容不会保留 - App Engine local datastore content does not persist Google App Engine DataStore - 如何以有效的方式从 Java 中子表的键中获取 select 父实体? - Google App Engine DataStore - How to select parent entities from keys of a child table in Java in an efficient way? App Engine Datastore IN Operator - 如何使用? - App Engine Datastore IN Operator - how to use? Google App Engine:java.lang.ClassCastException:com.google.appengine.api.datastore.Key 无法转换为 java.lang.Integer - Google App Engine: java.lang.ClassCastException: com.google.appengine.api.datastore.Key cannot be cast to java.lang.Integer 从谷歌应用引擎表单中的日期字段中提取数据 - pulling data from date field in google app engine form 谷歌应用引擎 JDO 3 - Google App Engine JDO 3 Google App Engine ModuleHostname:不是 App Engine 上下文 - Google App Engine ModuleHostname: not an App Engine context 是否有用于 Google App Engine(Java 语言)的 HTML 模板引擎? - Is there a HTML templating engine for Google App Engine (in Java)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM