From dc79454234a897de281bb21d05d9b5c49373e916 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 18 Jul 2024 11:32:48 -0700 Subject: [PATCH] Fix for np.int8 error, refs #632 Also refs: - https://github.com/simonw/llm/issues/531 --- sqlite_utils/db.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/sqlite_utils/db.py b/sqlite_utils/db.py index 6332dc26..6b3de87d 100644 --- a/sqlite_utils/db.py +++ b/sqlite_utils/db.py @@ -206,21 +206,25 @@ class Default: } # If numpy is available, add more types if np: - COLUMN_TYPE_MAPPING.update( - { - np.int8: "INTEGER", - np.int16: "INTEGER", - np.int32: "INTEGER", - np.int64: "INTEGER", - np.uint8: "INTEGER", - np.uint16: "INTEGER", - np.uint32: "INTEGER", - np.uint64: "INTEGER", - np.float16: "FLOAT", - np.float32: "FLOAT", - np.float64: "FLOAT", - } - ) + try: + COLUMN_TYPE_MAPPING.update( + { + np.int8: "INTEGER", + np.int16: "INTEGER", + np.int32: "INTEGER", + np.int64: "INTEGER", + np.uint8: "INTEGER", + np.uint16: "INTEGER", + np.uint32: "INTEGER", + np.uint64: "INTEGER", + np.float16: "FLOAT", + np.float32: "FLOAT", + np.float64: "FLOAT", + } + ) + except AttributeError: + # https://github.com/simonw/sqlite-utils/issues/632 + pass # If pandas is available, add more types if pd: