Sqlite3 cursors live updating?

孤者浪人 提交于 2019-12-02 01:04:46

SQLite computes results rows on demand, if possible. But this is not always possible, so there is no guarantee.

You should never modify any table that you are currently reading in another query. (The database might scan the table in unobvious ways, so even changes to other rows might change the enumeration.)

If you intend to do such modifications, you have to read all rows before doing the changes, e.g., for row in c.fetchall(). Alternatively, read the table in single steps that re-search for the place where the last query left, i.e.:

SELECT ... FROM MyTable WHERE ID > :LastID ORDER BY ID LIMIT 1;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!