constants.py 1.2 KB
Newer Older
1 2
# encoding:UTF-8

S
slguan 已提交
3 4 5
"""Constants in TDengine python
"""

6 7 8
import ctypes, struct


S
slguan 已提交
9
class FieldType(object):
10 11
    """TDengine Field Types"""

S
slguan 已提交
12 13 14 15 16 17 18 19 20 21 22 23
    # type_code
    C_NULL = 0
    C_BOOL = 1
    C_TINYINT = 2
    C_SMALLINT = 3
    C_INT = 4
    C_BIGINT = 5
    C_FLOAT = 6
    C_DOUBLE = 7
    C_BINARY = 8
    C_TIMESTAMP = 9
    C_NCHAR = 10
24 25 26 27
    C_TINYINT_UNSIGNED = 11
    C_SMALLINT_UNSIGNED = 12
    C_INT_UNSIGNED = 13
    C_BIGINT_UNSIGNED = 14
S
slguan 已提交
28 29 30 31
    # NULL value definition
    # NOTE: These values should change according to C definition in tsdb.h
    C_BOOL_NULL = 0x02
    C_TINYINT_NULL = -128
32
    C_TINYINT_UNSIGNED_NULL = 255
S
slguan 已提交
33
    C_SMALLINT_NULL = -32768
34
    C_SMALLINT_UNSIGNED_NULL = 65535
S
slguan 已提交
35
    C_INT_NULL = -2147483648
36
    C_INT_UNSIGNED_NULL = 4294967295
S
slguan 已提交
37
    C_BIGINT_NULL = -9223372036854775808
38
    C_BIGINT_UNSIGNED_NULL = 18446744073709551615
39 40
    C_FLOAT_NULL = ctypes.c_float(struct.unpack("<f", b"\x00\x00\xf0\x7f")[0])
    C_DOUBLE_NULL = ctypes.c_double(struct.unpack("<d", b"\x00\x00\x00\x00\x00\xff\xff\x7f")[0])
41
    C_BINARY_NULL = bytearray([int("0xff", 16)])
42
    # Timestamp precision definition
S
slguan 已提交
43 44
    C_TIMESTAMP_MILLI = 0
    C_TIMESTAMP_MICRO = 1
45 46
    C_TIMESTAMP_NANO = 2
    C_TIMESTAMP_UNKNOWN = 3