gpt4 book ai didi

python - 更改 GQL 中的数据

转载 作者:行者123 更新时间:2023-12-01 06:14:59 25 4
gpt4 key购买 nike

我需要更改条目的值,但以下代码不起作用。

logList = db.GqlQuery("SELECT * FROM Log ORDER BY date DESC LIMIT 1")
logList[0].content = "some text"
db.put(logList)

当我运行此命令时,最新元素的值不会改变。我用 Print 检查了输出,它给出了正确的值(内容字段应该更改的值和正确的旧值)并给出了以下状态代码:

Status: 302 Moved Temporarily
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Location: http://localhost:8080/admin/editl
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Length: 0

我的代码有什么问题吗? The used method of altering data官方文档中提到了。

最佳答案

logList = db.GqlQuery("SELECT * FROM Log ORDER BY date DESC LIMIT 1")
result = logList.get()
result.content = "some text"
result.put()

试试这个。您将 GqlQuery 对象与实际执行查询的结果混淆了。

关于python - 更改 GQL 中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3806023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com