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

增加api进行时间戳转换控制 #68

Open
kaybinwong opened this issue Jun 10, 2022 · 0 comments
Open

增加api进行时间戳转换控制 #68

kaybinwong opened this issue Jun 10, 2022 · 0 comments

Comments

@kaybinwong
Copy link

kaybinwong commented Jun 10, 2022

部分系统数据流转用的是时间戳,需要增加api控制是否进行时间戳转换。

目前是有入侵式地使用,2.2.1版本升级到2.3.5后有不兼容问题。

def _crow_timestamp_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN):
    """Function to convert C bool row to python row"""
    
    if precision == FieldType.C_TIMESTAMP_MILLI:
        _divide = 1e+3
    elif precision == FieldType.C_TIMESTAMP_MICRO:
        _divide = 1e+6
    elif precision == FieldType.C_TIMESTAMP_NANO:
        _divide = 1e+9
    else:
        raise DatabaseError("Unknown precision returned from database")

    return [
        None if ele == FieldType.C_BIGINT_NULL else ele / _divide
        for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_int64))[: abs(num_of_rows)]
    ]
@kaybinwong kaybinwong changed the title 增加api控制是否格式化时间戳 增加api进行时间戳转换控制 Jun 10, 2022
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