Use REAL not FLOAT as SQLite column type (#680)

* Use REAL not FLOAT as SQLite column type, refs #645
* Fix for REAL columns by CSV --detect-types

Refs https://github.com/simonw/sqlite-utils/issues/645#issuecomment-3568947189

* Removed note about strict and REAL
This commit is contained in:
Simon Willison 2025-11-23 21:37:59 -08:00 committed by GitHub
commit c872d27bb3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 61 additions and 37 deletions

View file

@ -189,7 +189,7 @@ class Default:
DEFAULT = Default()
COLUMN_TYPE_MAPPING = {
float: "FLOAT",
float: "REAL",
int: "INTEGER",
bool: "INTEGER",
str: "TEXT",
@ -203,19 +203,21 @@ COLUMN_TYPE_MAPPING = {
datetime.date: "TEXT",
datetime.time: "TEXT",
datetime.timedelta: "TEXT",
decimal.Decimal: "FLOAT",
decimal.Decimal: "REAL",
None.__class__: "TEXT",
uuid.UUID: "TEXT",
# SQLite explicit types
"TEXT": "TEXT",
"INTEGER": "INTEGER",
"FLOAT": "FLOAT",
"REAL": "REAL",
"BLOB": "BLOB",
"text": "TEXT",
"str": "TEXT",
"integer": "INTEGER",
"int": "INTEGER",
"float": "FLOAT",
"float": "REAL",
"real": "REAL",
"blob": "BLOB",
"bytes": "BLOB",
}
@ -232,9 +234,9 @@ if np:
np.uint16: "INTEGER",
np.uint32: "INTEGER",
np.uint64: "INTEGER",
np.float16: "FLOAT",
np.float32: "FLOAT",
np.float64: "FLOAT",
np.float16: "REAL",
np.float32: "REAL",
np.float64: "REAL",
}
)
except AttributeError: