因此,当我运行从 sqlite 数据库中提取大量数据的代码时,
我的 python 代码中出现以下错误!
(<type 'exceptions.MemoryError'>, 'main.py', 427)
是的,上面的异常是我自己的一些错误格式。
在它只是打印之前MemoryError
这就是我在第 427 行的内容:
rows=cur.fetchall()
然后我假设问题与内存有关:所以我做了以下
sqlite> PRAGMA page_size = 1073741824;
sqlite> PRAGMA cache_size = 100000;
sqlite> VACUUM;
sqlite> PRAGMA page_size;
4096
Memory Used: 50186800 (max 100373936) bytes
Number of Outstanding Allocations: 12075 (max 24216)
Number of Pcache Overflow Bytes: 50045536 (max 100095168) bytes
Number of Scratch Overflow Bytes: 0 (max 11392) bytes
Largest Allocation: 469214 bytes
Largest Pcache Allocation: 4244 bytes
Largest Scratch Allocation: 11392 bytes
Lookaside Slots Used: 0 (max 0)
Successful lookaside attempts: 0
Lookaside failures due to size: 0
Lookaside failures due to OOM: 0
Pager Heap Usage: 49904696 bytes
Page cache hits: 2011
Page cache misses: 21561
Page cache writes: 11780
Schema Heap Usage: 7296 bytes
Statement Heap/Lookaside Usage: 1448 bytes
Fullscan Steps: 0
Sort Operations: 0
Autoindex Inserts: 0
sqlite>
sqlite> .version
SQLite 3.7.13 2012-06-11 02:05:22
但我仍然得到同样的错误。
想法?
编辑:
每个答案打击,尝试:
rows = []
while True:
rows.append(cur.fetchone())
但同样的结果。