Python:sqlite3.Cursor.execute 是懒惰的吗?

标签 python sqlite

sqlite3.Cursor.__iter__ 方法是懒惰的吗? IE。它是预先计算所有行,然后在迭代时生成它们,还是仅在我迭代它们时才计算行?我问这个问题是因为我正在考虑是否向我的 SQL 查询添加 LIMIT 子句。

最佳答案

SQLite C API 是惰性的; sqlite3_step函数即时计算下一个结果行。

对于 Python 的 sqlite3 模块,source code显示 pysqlite_cursor_iternext 函数调用 pysqlite_step 一次。

关于Python:sqlite3.Cursor.execute 是懒惰的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25424348/

相关文章:

python矩阵乘法: how to handle very large matrices?

Python将变量的内容复制到剪贴板

python - zipline 安装错误 : failed building wheel for bcolz

python - 获取对象的外键父级 - Django

c# - 如何创建密码保护的数据库?

java - ORMLite 异常 : java. sql.SQLException: ResultSet 已请求

sqlite - 如何打开文件:///private/var/mobile/Containers/Shared/AppGroup/folder on Mac?

python - 为什么 mypy 说我有太多的争论

android - 如何在React原生sqlite数据库中使用upsert

android - 如何使用 CursorAdapter?