Skip to main content
 首页 » 编程设计

Python sqlite3 查询在终端中有效,但在应用程序中无效

2025年05月04日15Free-Thinker

已经看过这些类似的问题,但没有任何乐趣:

PHP MySQL Query doesn't work, but works from terminal Sqlite update don't working right - python

我正在使用带有 SQLite 的 Flask 并有以下查询:

g.db.execute( "UPDATE article_views SET views=views+1 WHERE id=:id" , { "id": this_id } ) 

其中 this_id 是一个整数。这执行没有错误。但是当我检查我的数据库时,没有发生预期的更新。

有没有人对此有任何见解?

请您参考如下方法:

我怀疑你需要 commit your transaction也是:

g.db.commit()