gpt4 book ai didi

python - Web.py db.insert() 不插入行

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

我正在使用 Web.py 0.37,并尝试向我的 mysql 数据库中添加一行。这是我的代码:

com.globals.db.insert('users', email=data.email, fullname=data.fullname, password=pwh, _test=False)

这是输出(在调试器窗口中):

0.09 (2): INSERT INTO users (fullname, password, email) VALUES ('Juan', 'f3bab99...d05cee4', 'no@email.com')
0.09 (3): SELECT last_insert_id();
30

我可以看到 id 字段递增,但是当我检查数据库时,没有创建新行。为什么会这样?输出的sql语句在mysql终端执行正常。

最佳答案

你提交数据了吗?

很可能您正在使用事务并且需要提交数据才能在其他进程中看到它。

虽然我不知道如何在 Web.py 中执行此操作!

(根据 Helgi 的建议从我的原始评论中复制)

关于python - Web.py db.insert() 不插入行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10745963/

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