pgref.dev/sqlite/errors/SQLITE_FULL
SQLITE_FULLERRORTier 2 — Caution✅ HIGH confidence

database or disk is full

Category: Resource LimitVersions: All SQLite versions

What this means

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.

Why it happens

  1. 1The filesystem containing the database file has 0 bytes of free space
  2. 2The PRAGMA max_page_count limit has been reached and the database cannot grow further
  3. 3The temporary file directory (TMPDIR) is full and SQLite cannot write a journal file

How to reproduce

The max_page_count is set to a very small value and then exceeded.

trigger — this will ERROR
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 full
database or disk is full

Fix 1: Free disk space

When the filesystem is full.

fix
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 the page limit was set too low for the application's data volume.

fix
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.

What not to do

Catch SQLITE_FULL and retry the same write immediately

Why it's wrong: Without freeing space the retry will fail immediately with the same error, creating an infinite loop.

Version notes

All versionsSQLITE_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.

Sources

📚 Official docs: https://www.sqlite.org/rescode.html#full

🔧 Source ref: sqlite3.h — SQLITE_FULL = 13

📖 Further reading: PRAGMA max_page_count

Confidence assessment

✅ HIGH confidence

Stable and well-documented. The statement-rollback-but-open-transaction behaviour is documented in the result code page.

See also

📄 Reference pages

PRAGMA max_page_countPRAGMA page_size
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →