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

标签 python mysql web.py

我正在使用 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/

相关文章:

python - 如何在python中搜索并获取DLL文件的目录

php - 根据特定条件运行 SQL 查询并仅删除 x 行?

python - Web.py session 数据在生产中消失

java - 无法在jsp页面中调用servlet的doPost()方法

MYSQL:IF语句查找n行中的空列

http - 从 Web.py 中的 PUT 方法获取输入

Python Storm /web.py : Correctly handling DisconnectionError with MySQL database

python - 清理从文件 python 中读取的字符串

python - dict 类是做什么用的

python - 在虚拟环境中安装我自己的 python 模块