[英]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.