gpt4 book ai didi

python - Mysql使用webpy更新表

转载 作者:行者123 更新时间:2023-11-29 12:26:51 25 4
gpt4 key购买 nike

我希望使用 db.update 在 webpy 中实现以下查询

  update emp set age=age+1 where x=1`

当我尝试

 db.update('emp',where='x=1',age=age+1)

这给我一个错误,说全局名称“age”未定义

最佳答案

你应该使用db.query来代替,就像这样results = db.query("UPDATE emp SET Age=age+1 WHERE x=$x", vars={'x':1})

关于python - Mysql使用webpy更新表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28191210/

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