From f4abb77d7bf5f98b9d203b504c3d9e8f8a74b4a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemen=20Tu=C5=A1ar?= Date: Sat, 20 Jul 2024 20:10:59 +0100 Subject: [PATCH] :sparkles: use dateutil to parse SQLite dates --- src/mysql_to_sqlite3/sqlite_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mysql_to_sqlite3/sqlite_utils.py b/src/mysql_to_sqlite3/sqlite_utils.py index ac68104..71f331b 100644 --- a/src/mysql_to_sqlite3/sqlite_utils.py +++ b/src/mysql_to_sqlite3/sqlite_utils.py @@ -5,7 +5,7 @@ from datetime import date, timedelta from decimal import Decimal -from dateutil.parser import parse as dateutil_parse +from dateutil.parser import parse as dateutil_parse, ParserError from pytimeparse2 import parse @@ -51,7 +51,7 @@ def convert_date(value: t.Union[str, bytes]) -> date: """Handle SQLite date conversion.""" try: return dateutil_parse(value.decode() if isinstance(value, bytes) else value).date() - except ValueError as err: + except ParserError as err: raise ValueError(f"DATE field contains {err}") # pylint: disable=W0707