code: def convert_to_database_compatible_value(value):
      
      if pd.isnull(value):
          return None
      if isinstance(value, pd.Timestamp):
          return value.to_pydatetime()
      try:
          return value.item()
      except AttributeError:
          return value
docs: Pandas 0.23 broke DataFrame.to_sql, so we workaround it by rolling our
      own extremely low-tech conversion routine