Skip to content

Commit 734fb2c

Browse files
committed
refactor: Drop redundant output converter.
DATETIMEOFFSET is natively supported by `mssql-python`. See "microsoft/mssql-python#213" Signed-off-by: walanguzzi <walanguzzi@outlook.com>
1 parent 97ddffa commit 734fb2c

1 file changed

Lines changed: 0 additions & 23 deletions

File tree

sqlmesh/core/config/connection.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,29 +1702,6 @@ def connect_mssql_python(**kwargs: t.Any) -> t.Callable:
17021702

17031703
conn = mssql_python.connect(conn_str, autocommit=kwargs.get("autocommit", False))
17041704

1705-
# Set up output converters for MSSQL-specific data types
1706-
# Handle SQL type -155 (DATETIMEOFFSET) which is not yet supported by pyodbc
1707-
# ref: https://github.com/mkleehammer/pyodbc/issues/134#issuecomment-281739794
1708-
def handle_datetimeoffset_mssql_python(dto_value: t.Any) -> t.Any:
1709-
import struct
1710-
from datetime import datetime, timedelta, timezone
1711-
1712-
# Unpack the DATETIMEOFFSET binary format:
1713-
# Format: <6hI2h = (year, month, day, hour, minute, second, nanoseconds, tz_hour_offset, tz_minute_offset)
1714-
tup = struct.unpack("<6hI2h", dto_value)
1715-
return datetime(
1716-
tup[0],
1717-
tup[1],
1718-
tup[2],
1719-
tup[3],
1720-
tup[4],
1721-
tup[5],
1722-
tup[6] // 1000,
1723-
timezone(timedelta(hours=tup[7], minutes=tup[8])),
1724-
)
1725-
1726-
conn.add_output_converter(-155, handle_datetimeoffset_mssql_python)
1727-
17281705
return conn
17291706

17301707
return connect_mssql_python

0 commit comments

Comments
 (0)