0

I am using sqlite3 in python, the program runns in different threads. Sqlite3 resides only in one thread. After a while the sqlite3 thread takes ot much memory.

How can I limit the maximum amount of memory sqlite3 uses?

What are rules of tumb about the maximal memory size?

4

1 回答 1

2

您可以将 PRAGMA 语句传递给游标对象以更改当前会话的数据库行为。

PRAGMA 语句使用与其他 SQLite 命令(例如 SELECT、INSERT)相同的接口发出

>>> import sqlite3
>>> conn = sqlite3.connect(FILENAME)
>>> cur = conn.cursor()
>>> cur.execute("PRAGMA cache_size = -512") # Negative value means use N * 1024 bytes of memory.
<sqlite3.Cursor object at 0x01F14260>

来自 SQLite 文档:http ://www.sqlite.org/pragma.html#pragma_cache_size

于 2013-01-03T20:56:44.117 回答