How to Check Which Python Type Each SQLite Value Comes Back As
SQLite has only five kinds of value, and Python has many more types. Knowing how sqlite3 moves between them tells you what comes back from a query, and why True returns as 1. This guide stores one value of each kind and prints the Python type of each, with real output from Python 3.15.2.
How sqlite3 Converts Values
Python's sqlite3 documentation: "SQLite natively supports the following types: NULL, INTEGER, REAL, TEXT, BLOB." By default, sqlite3 converts like this:
| Python type you store | SQLite type | Python type you read back |
|---|---|---|
None | NULL | None |
int | INTEGER | int |
float | REAL | float |
str | TEXT | str |
bytes | BLOB | bytes |
Any other type has to be turned into one of these first.
Prerequisites
- uv and Python. This guide uses uv 0.13.10 with Python 3.15.2, in a project made with
uv init.
Step 1: Write the Script
The table has one column for each kind of value, plus in_stock, which stores True:
import sqlite3
connection = sqlite3.connect(":memory:")
connection.execute(
"CREATE TABLE items (quantity INTEGER, price REAL, name TEXT,"
" note TEXT, photo BLOB, in_stock INTEGER)"
)
connection.execute(
"INSERT INTO items VALUES (?, ?, ?, ?, ?, ?)", (3, 4.5, "lantern", None, b"\x89PNG", True)
)
row = connection.execute("SELECT * FROM items").fetchone()
for value in row:
print(f"{value!r}: {type(value).__name__}")
connection.close()

- The six values are an
int, afloat, astr,None,bytesand abool. type(value).__name__prints the name of each value's Python type after the round trip.
Step 2: Run It
uv run python sqlite_types.py
3: int
4.5: float
'lantern': str
None: NoneType
b'\x89PNG': bytes
1: int

The first five came back exactly as they went in. The last one didn't: SQLite has no true-or-false type, so True was stored as the integer 1, and it came back as 1, an int.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Expecting True back from a column that stored True | You get 1, an int | Turn it back with bool(value) |
Storing a datetime.date | It works, but warns: DeprecationWarning: The default date adapter is deprecated as of Python 3.12; see the sqlite3 documentation for suggested replacement recipes. And it comes back as the text '2026-11-20' | Store date.isoformat() yourself and read it with date.fromisoformat() |
Storing a Decimal | sqlite3.ProgrammingError: Error binding parameter 1: type 'decimal.Decimal' is not supported | Store money as whole cents, an int |
| Storing a list | sqlite3.ProgrammingError: Error binding parameter 1: type 'list' is not supported | Store it as JSON text, or in its own table |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Error binding parameter N: type '...' is not supported | The value's type isn't one of the five sqlite3 stores | Convert it before the query |
FAQ
Why did a date come back as text?
SQLite has no date type. The deprecated default adapter wrote the date as text, and nothing turns it back. Python's documentation has adapter and converter recipes to replace it.
Can I read TEXT as something other than str?
Yes: the conversion "depends on text_factory, str by default", as the documentation's table puts it.
Conclusion
3, 4.5, 'lantern', None and the bytes came back as the same Python types, while True came back as 1, because SQLite stores it as an integer.
Additional Resources
- SQLite and Python types — the conversion tables.
- Adapter and converter recipes — storing dates and other types.
