# sqlite3.OperationalError: disk I/O error

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

## Root Cause

SQLite encounters an operating system-level input/output error while reading or writing the database file, typically due to filesystem corruption, disk failure, or insufficient permissions on the storage device.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| SQLite 3.39 | active | — | — |
| SQLite 3.40 | active | — | — |
| SQLite 3.43 | active | — | — |

## Workarounds

1. **Run fsck on the filesystem (e.g., sudo fsck /dev/sda1) or on Windows run chkdsk /f C:. This may fix underlying corruption.** (70% success)
   ```
   Run fsck on the filesystem (e.g., sudo fsck /dev/sda1) or on Windows run chkdsk /f C:. This may fix underlying corruption.
   ```
2. **Copy the .db file to another disk: cp mydb.db /healthy_disk/mydb.db. Then run: sqlite3 /healthy_disk/mydb.db 'PRAGMA integrity_check;'. If it passes, use the copy.** (80% success)
   ```
   Copy the .db file to another disk: cp mydb.db /healthy_disk/mydb.db. Then run: sqlite3 /healthy_disk/mydb.db 'PRAGMA integrity_check;'. If it passes, use the copy.
   ```
3. **Run: sqlite3 corrupted.db '.dump' | sqlite3 new.db. This recreates the database from scratch, skipping corrupted pages if possible.** (75% success)
   ```
   Run: sqlite3 corrupted.db '.dump' | sqlite3 new.db. This recreates the database from scratch, skipping corrupted pages if possible.
   ```

## Dead Ends

- **** — The underlying I/O issue persists; reopening will trigger the same error immediately. (100% fail)
- **** — VACUUM requires a temporary file and may fail with the same I/O error if the disk is full or damaged. (80% fail)
- **** — WAL mode still writes to disk; if the disk is faulty, the error will recur. (90% fail)
