# sqlite3.DatabaseError: disk I/O error

- **ID:** `database/sqlite-disk-i-o-error`
- **Domain:** database
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 75%

## Root Cause

SQLite encountered a filesystem-level read or write failure, often due to disk corruption, insufficient permissions, or a full filesystem.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| SQLite 3.40 | active | — | — |
| SQLite 3.41 | active | — | — |
| SQLite 3.42 | active | — | — |
| Python 3.11 | active | — | — |
| Python 3.12 | active | — | — |

## Workarounds

1. **Check filesystem health using fsck (Linux) or chkdsk (Windows). Example: sudo fsck /dev/sda1 or chkdsk C: /f. Then attempt to recover the database using sqlite3 .recover.** (70% success)
   ```
   Check filesystem health using fsck (Linux) or chkdsk (Windows). Example: sudo fsck /dev/sda1 or chkdsk C: /f. Then attempt to recover the database using sqlite3 .recover.
   ```
2. **If the error is due to permissions, ensure the SQLite process has write access to the database file and its directory. Example: chmod 664 /path/to/database.db && chown www-data:www-data /path/to/database.db** (85% success)
   ```
   If the error is due to permissions, ensure the SQLite process has write access to the database file and its directory. Example: chmod 664 /path/to/database.db && chown www-data:www-data /path/to/database.db
   ```
3. **Use SQLite's built-in integrity check and repair: sqlite3 database.db "PRAGMA integrity_check;" then backup and restore: sqlite3 database.db ".backup backup.db"** (75% success)
   ```
   Use SQLite's built-in integrity check and repair: sqlite3 database.db "PRAGMA integrity_check;" then backup and restore: sqlite3 database.db ".backup backup.db"
   ```

## Dead Ends

- **Delete the database file and recreate it from scratch.** — This causes data loss and does not address the underlying disk issue; the new file may also get corrupted if the root cause persists. (90% fail)
- **Increase the SQLite cache size to reduce disk writes.** — Cache size adjustments do not fix physical disk I/O errors; they only affect performance, not reliability. (80% fail)
