You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The datatype mapper provided by pyexasol (pyexasol.mapper.exasol_mapper) currently does not support TIMESTAMP WITH LOCAL TIME ZONE, which may cause inconvenience to the user. Adding support for this data type would improve the usability of pyexasol.
Details
The pyexasol library provides a datatype mapper to convert the Exasol data types to Python data types. However, the current implementation does not support the TIMESTAMP WITH LOCAL TIME ZONE data type. This means that when a user tries to fetch data from a column of this type, they will receive a string.
Until this is addressed, we suggest creating a custom mapper that adds support for TIMESTAMP WITH LOCAL TIME ZONE (see examples).
Examples
Current behavior
importpyexasolfrompyexasolimportmappercon=pyexasol.connect(dsn='127.0.0.1:8563', user='sys', password='exasol', fetch_mapper=mapper.exasol_mapper)
# This returns a datetime.datetime objectquery="SELECT CAST('2022-01-01 01:00:00.000000' AS TIMESTAMP WITH LOCAL TIME ZONE) AS timestamp_col"result=con.execute(query).fetchall()
print(result)
# This returns a string objectquery="SELECT CAST('2022-01-01 01:00:00.000000' AS TIMESTAMP WITH LOCAL TIME ZONE) AS timestamp_col"result=con.execute(query).fetchall()
print(result)
Custom mapper adding support for TIMESTAMP WITH LOCAL TIME ZONE
importpyexasolfrompyexasolimportmapperfromdateutil.tzimporttzlocaldefmy_mapper(value, data_type):
ifnotvalue:
returnNoneifdata_type['type'] =="TIMESTAMP WITH LOCAL TIME ZONE":
# convert to datetime object with local timezonevalue=value.astimezone(tzlocal())
returnmapper.exasol_mapper(value, data_type)
con=pyexasol.connect(dsn='127.0.0.1:8563', user='sys', password='exasol', fetch_mapper=my_mapper)
The text was updated successfully, but these errors were encountered:
Summary
The datatype mapper provided by pyexasol (
pyexasol.mapper.exasol_mapper
) currently does not supportTIMESTAMP WITH LOCAL TIME ZONE
, which may cause inconvenience to the user. Adding support for this data type would improve the usability of pyexasol.Details
The pyexasol library provides a datatype mapper to convert the Exasol data types to Python data types. However, the current implementation does not support the
TIMESTAMP WITH LOCAL TIME ZONE
data type. This means that when a user tries to fetch data from a column of this type, they will receive a string.Until this is addressed, we suggest creating a custom mapper that adds support for
TIMESTAMP WITH LOCAL TIME ZONE
(see examples).Examples
Current behavior
Custom mapper adding support for
TIMESTAMP WITH LOCAL TIME ZONE
The text was updated successfully, but these errors were encountered: