From fdf7cb4a9811f8d78ae921740efb7ba452270cb8 Mon Sep 17 00:00:00 2001 From: bob <32605365+b0b5h4rp13@users.noreply.github.com> Date: Sun, 29 Mar 2020 09:36:30 -0400 Subject: [PATCH] Add type conversion for Panda's Timestamp Add type conversion for Panda's Timestamp, if Panda library is present in system (thanks for this project, I was about to do the same thing from scratch) --- sqlite_utils/db.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sqlite_utils/db.py b/sqlite_utils/db.py index 15fdcfb..8f38330 100644 --- a/sqlite_utils/db.py +++ b/sqlite_utils/db.py @@ -8,6 +8,12 @@ import pathlib SQLITE_MAX_VARS = 999 + +try: + import pandas as pd +except ImportError: + pd = None + try: import numpy as np except ImportError: @@ -64,6 +70,13 @@ if np: } ) +# If pandas is available, add more types +if pd: + COLUMN_TYPE_MAPPING.update( + { + pd.Timestamp: "TEXT" + }) + class AlterError(Exception): pass