-
-
Notifications
You must be signed in to change notification settings - Fork 121
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Trying to create a table with float columns fails when strict mode is enabled.
Running this snippet:
from sqlite_utils import Database
db = Database("test.db")
db["test"].create({"frequency": float}, strict=True)
Causes this error:
Traceback (most recent call last):
File "/home/agateau/tmp/sqliteutilsfloat.py", line 4, in <module>
db["test"].create({"frequency": float}, strict=True)
File "/home/agateau/.local/share/virtualenvs/40d64b18be55921/lib/python3.10/site-packages/sqlite_utils/db.py", line 1689, in create
self.db.create_table(
File "/home/agateau/.local/share/virtualenvs/40d64b18be55921/lib/python3.10/site-packages/sqlite_utils/db.py", line 1070, in create_table
self.execute(sql)
File "/home/agateau/.local/share/virtualenvs/40d64b18be55921/lib/python3.10/site-packages/sqlite_utils/db.py", line 526, in execute
return self.conn.execute(sql)
sqlite3.OperationalError: unknown datatype for test.frequency: "FLOAT"
According to sqlite doc, the type for floats should be REAL
. To verify this I modified db.py so that COLUMN_TYPE_MAPPING
would return "REAL"
for float
. With this modification the example snippet runs.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working