SQLite: datatype mismatch (SQLITE_MISMATCH)
SQLite refused a value for a column with strict typing, such as a non-integer for an INTEGER PRIMARY KEY or a STRICT table column.
datatype mismatchsqlite3.IntegrityError: datatype mismatchError: SQLITE_MISMATCH: datatype mismatchcannot store TEXT value in INTEGER column Meaning
INTEGER PRIMARY KEY accepts only integers; STRICT tables enforce column types. Cast or fix the value, and don't store UUID strings in an INTEGER PRIMARY KEY (use TEXT PRIMARY KEY).
Common causes
- Text inserted into INTEGER PRIMARY KEY
- STRICT table type violation
- UUID in an integer key column
- Wrong parameter order
- ORM sending the wrong type
⚡ Quick fix
- Use TEXT keys for UUIDs
- Cast/validate before inserting
- Check the table definition (
.schema)
Detailed fix by platform
SQL
CREATE TABLE items (id TEXT PRIMARY KEY, qty INTEGER); -- not INTEGER PRIMARY KEY for UUIDs
How to diagnose
- Column — INTEGER PRIMARY KEY?
- Value — Integer?
- Table — STRICT?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in SQL
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 18 Nov 2026