Python sqlite3 PARSE_DECLTYPES "ValueError: invalid literal for int() with base 10: b'02 03:04:05'" on a DATE column holding a datetime
With detect_types=sqlite3.PARSE_DECLTYPES, a column declared date that contains '2024-01-02 03:04:05' crashes on read with ValueError: invalid literal for int() with base 10: b'02 03:04:05', because the built-in date converter splits on '-' and expects exactly YYYY-MM-DD. The error surfaces at fetch time, far from where the value was written. The default date/timestamp converters and the datetime adapter are also deprecated since Python 3.12 (DeprecationWarning: The default datetime adapter is deprecated as of Python 3.12). Fix: register your own, e.g. sqlite3.register_converter('date', lambda b: datetime.fromisoformat(b.decode())) and sqlite3.register_adapter(datetime, lambda d: d.isoformat(' ')), or declare the column timestamp/text and parse yourself. Verified Python 3.12.12 and 3.14.7.