Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Data Types] Datetimeoffset / Time handlers #334

Open
Platob opened this issue Jan 23, 2022 · 0 comments
Open

[Data Types] Datetimeoffset / Time handlers #334

Platob opened this issue Jan 23, 2022 · 0 comments

Comments

@Platob
Copy link

Platob commented Jan 23, 2022

Hello,

Is there a way to recover data with datetimeoffset, time data type without convertion in sql query ?

I see also that precision and scale aren't recovered with same driver like 'SQL Server Native Client 11.0', any update to add it later ?

Br
Nicolas

RuntimeError: Error! Unsupported type identifier for column datetimeoffset @ NULLABLE UNKNOWN TYPE (precision 34, scale 7))
RuntimeError: Error! Unsupported type identifier for column time @ NULLABLE UNKNOWN TYPE (precision 16, scale 7))

For example with classic pyodbc:

I can add converters for type, it force convertion to UTC because i cannot recover timezone from cursor.description

def handle_datetime_offset(dto_value):
    tup = struct.unpack("<6hI2h", dto_value)  # e.g., (2017, 3, 16, 10, 35, 18, 500000000, -6, 0)
    ns = numpy.datetime64(
        f"{tup[0]:04}-{tup[1]:02}-{tup[2]:02} {tup[3]:02}:{tup[4]:02}:{tup[5]:02}.{tup[6]:09}", "ns"
    ).astype(datetime.datetime)
    return ns - tup[7] * 3600 * 1000000000 - tup[8] * 60 * 1000000000


PYARROW_CONVERTERS = {
    -155: handle_datetime_offset
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant