taosdata / taosdata/taos-connector-python

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

Open
#68 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
61
Forks
17
PR merge metrics
No merged PRs in 30d

Description

部分系统数据流转用的是时间戳,需要增加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)]
    ]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating _crow_timestamp_to_python and tracing where timestamp values are converted in the connector. Determine how an API can control that conversion and review the 2.2.1-to-2.3.5 incompatibility described in the issue. Done means callers have explicit control over timestamp conversion without the current intrusive behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.