Skip to content

Commit dc79454

Browse files
authored
Fix for np.int8 error, refs #632
Also refs: - simonw/llm#531
1 parent 577078f commit dc79454

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

sqlite_utils/db.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -206,21 +206,25 @@ class Default:
206206
}
207207
# If numpy is available, add more types
208208
if np:
209-
COLUMN_TYPE_MAPPING.update(
210-
{
211-
np.int8: "INTEGER",
212-
np.int16: "INTEGER",
213-
np.int32: "INTEGER",
214-
np.int64: "INTEGER",
215-
np.uint8: "INTEGER",
216-
np.uint16: "INTEGER",
217-
np.uint32: "INTEGER",
218-
np.uint64: "INTEGER",
219-
np.float16: "FLOAT",
220-
np.float32: "FLOAT",
221-
np.float64: "FLOAT",
222-
}
223-
)
209+
try:
210+
COLUMN_TYPE_MAPPING.update(
211+
{
212+
np.int8: "INTEGER",
213+
np.int16: "INTEGER",
214+
np.int32: "INTEGER",
215+
np.int64: "INTEGER",
216+
np.uint8: "INTEGER",
217+
np.uint16: "INTEGER",
218+
np.uint32: "INTEGER",
219+
np.uint64: "INTEGER",
220+
np.float16: "FLOAT",
221+
np.float32: "FLOAT",
222+
np.float64: "FLOAT",
223+
}
224+
)
225+
except AttributeError:
226+
# https://github.com/simonw/sqlite-utils/issues/632
227+
pass
224228

225229
# If pandas is available, add more types
226230
if pd:

0 commit comments

Comments
 (0)