database or disk is full
SQLITE_FULL (result code 13) is returned when SQLite cannot complete a write because either the filesystem has no remaining space, or the database has reached the configured maximum page limit (max_page_count PRAGMA). SQLite rolls back the current statement to avoid a partial write, but the enclosing transaction remains open.
- 1The filesystem containing the database file has 0 bytes of free space
- 2The PRAGMA max_page_count limit has been reached and the database cannot grow further
- 3The temporary file directory (TMPDIR) is full and SQLite cannot write a journal file
The max_page_count is set to a very small value and then exceeded.
import sqlite3
conn = sqlite3.connect(':memory:')
conn.execute('PRAGMA max_page_count = 5')
conn.execute('CREATE TABLE t (data TEXT)')
try:
for i in range(1000):
conn.execute('INSERT INTO t VALUES (?)', ('x' * 4096,))
except Exception as e:
print(e) # database or disk is fullexpected output
database or disk is full
Fix 1
Free disk space
WHEN When the filesystem is full.
import shutil
total, used, free = shutil.disk_usage('/var/data')
print(f"Free: {free // (1024**2)} MB")
# Delete old log files, archives, or old database backups, then retry.Why this works
SQLITE_FULL cannot be resolved at the SQL level when caused by a full filesystem. The application must free space externally and then resume the transaction.
Fix 2
Increase or remove max_page_count
WHEN When the page limit was set too low for the application's data volume.
import sqlite3
conn = sqlite3.connect('mydb.db')
# Remove the artificial cap (default is 2^31 - 1)
conn.execute('PRAGMA max_page_count = 2147483647')Why this works
max_page_count is a soft limit stored per-connection — it is not persisted in the database file. Increasing it removes the artificial ceiling on database size.
✕ Catch SQLITE_FULL and retry the same write immediately
Without freeing space the retry will fail immediately with the same error, creating an infinite loop.
SQLITE_FULL causes an automatic statement rollback. The enclosing transaction (if any) remains open and can be explicitly rolled back or committed with whatever data was already written.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev