code: def before(self, i):
          
          if not isinstance(i, datetime):
              raise TypeError("'{}' is not a datetime object".format(i))
          else:
              result = self._connection.execute(
                  """SELECT {selkeycol} FROM {table} WHERE
                  {keycol} < :key ORDER BY {keycol} DESC LIMIT 1;
                  """.format(
                      selkeycol=self.selkeycol,
                      table=self.table,
                      keycol=self._keycol
                  ), {"key":i}).fetchone()
          return result[self._keycol] if result is not None else None
docs: Return datetime of newest existing data record whose datetime
          is < idx. If no such record exists, return None.