Types

INTEGER, REAL, TEXT, NULL.

SQLite storage classes are INTEGER, REAL, TEXT, BLOB, NULL. Python int/float/str/None map cleanly.

Goal

Insert mixed types and print typeof for each column.

import sqlite3
con = sqlite3.connect(":memory:")
con.execute("CREATE TABLE t (n INTEGER, x REAL, s TEXT)")
con.execute("INSERT INTO t VALUES (?, ?, ?)", (12, 10.5, "Nairobi"))
print(con.execute("SELECT typeof(n), typeof(x), typeof(s) FROM t").fetchone())
con.close()
import sqlite3
con = sqlite3.connect(":memory:")
con.execute("CREATE TABLE t (n INTEGER)")
con.execute("INSERT INTO t VALUES ('12')")
print(con.execute("SELECT n, typeof(n) FROM t").fetchone())
con.close()
import sqlite3
con = sqlite3.connect(":memory:")
con.execute("CREATE TABLE t (s TEXT)")
con.execute("INSERT INTO t VALUES (12)")
print(con.execute("SELECT s, typeof(s) FROM t").fetchone())
con.close()
import sqlite3
con = sqlite3.connect(":memory:")
print(con.execute("SELECT 1 / 2, 1.0 / 2").fetchone())
con.close()