[TD-2971] <feature>: make python connector support unsigned int. fix None determine.
This commit is contained in:
parent
da32a2571e
commit
450bf068f9
|
@ -67,13 +67,13 @@ def _crow_tinyint_unsigned_to_python(
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_byte))[
|
ctypes.c_ubyte))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
else:
|
else:
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_byte))[
|
ctypes.c_ubyte))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,13 +102,13 @@ def _crow_smallint_unsigned_to_python(
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_short))[
|
ctypes.c_ushort))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
else:
|
else:
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_short))[
|
ctypes.c_ushort))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,13 +130,13 @@ def _crow_int_unsigned_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_INT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_INT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_int))[
|
ctypes.c_uint))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
else:
|
else:
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_INT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_INT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_int))[
|
ctypes.c_uint))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,13 +162,13 @@ def _crow_bigint_unsigned_to_python(
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_long))[
|
ctypes.c_ulong))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
else:
|
else:
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_long))[
|
ctypes.c_ulong))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,13 +67,13 @@ def _crow_tinyint_unsigned_to_python(
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_byte))[
|
ctypes.c_ubyte))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
else:
|
else:
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_byte))[
|
ctypes.c_ubyte))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,13 +102,13 @@ def _crow_smallint_unsigned_to_python(
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_short))[
|
ctypes.c_ushort))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
else:
|
else:
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_short))[
|
ctypes.c_ushort))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,13 +130,13 @@ def _crow_int_unsigned_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_INT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_INT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_int))[
|
ctypes.c_uint))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
else:
|
else:
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_INT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_INT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_int))[
|
ctypes.c_uint))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,13 +162,13 @@ def _crow_bigint_unsigned_to_python(
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_long))[
|
ctypes.c_ulong))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
else:
|
else:
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_long))[
|
ctypes.c_ulong))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
@ -523,7 +523,6 @@ class CTaosInterface(object):
|
||||||
for i in range(len(fields)):
|
for i in range(len(fields)):
|
||||||
data = ctypes.cast(pblock, ctypes.POINTER(ctypes.c_void_p))[i]
|
data = ctypes.cast(pblock, ctypes.POINTER(ctypes.c_void_p))[i]
|
||||||
if fields[i]['type'] not in _CONVERT_FUNC_BLOCK:
|
if fields[i]['type'] not in _CONVERT_FUNC_BLOCK:
|
||||||
print("CBD cinterface.py LN526")
|
|
||||||
raise DatabaseError("Invalid data type returned from database")
|
raise DatabaseError("Invalid data type returned from database")
|
||||||
blocks[i] = _CONVERT_FUNC_BLOCK[fields[i]['type']](
|
blocks[i] = _CONVERT_FUNC_BLOCK[fields[i]['type']](
|
||||||
data, num_of_rows, fieldLen[i], isMicro)
|
data, num_of_rows, fieldLen[i], isMicro)
|
||||||
|
@ -548,7 +547,6 @@ class CTaosInterface(object):
|
||||||
for i in range(len(fields)):
|
for i in range(len(fields)):
|
||||||
data = ctypes.cast(pblock, ctypes.POINTER(ctypes.c_void_p))[i]
|
data = ctypes.cast(pblock, ctypes.POINTER(ctypes.c_void_p))[i]
|
||||||
if fields[i]['type'] not in _CONVERT_FUNC:
|
if fields[i]['type'] not in _CONVERT_FUNC:
|
||||||
print("CBD cinterface.py LN551")
|
|
||||||
raise DatabaseError(
|
raise DatabaseError(
|
||||||
"Invalid data type returned from database")
|
"Invalid data type returned from database")
|
||||||
if data is None:
|
if data is None:
|
||||||
|
|
|
@ -67,13 +67,13 @@ def _crow_tinyint_unsigned_to_python(
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_byte))[
|
ctypes.c_ubyte))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
else:
|
else:
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_byte))[
|
ctypes.c_ubyte))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,13 +102,13 @@ def _crow_smallint_unsigned_to_python(
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_short))[
|
ctypes.c_ushort))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
else:
|
else:
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_short))[
|
ctypes.c_ushort))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,13 +130,13 @@ def _crow_int_unsigned_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_INT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_INT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_int))[
|
ctypes.c_uint))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
else:
|
else:
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_INT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_INT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_int))[
|
ctypes.c_uint))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,13 +162,13 @@ def _crow_bigint_unsigned_to_python(
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_long))[
|
ctypes.c_ulong))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
else:
|
else:
|
||||||
return [
|
return [
|
||||||
None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(
|
data, ctypes.POINTER(
|
||||||
ctypes.c_long))[
|
ctypes.c_ulong))[
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,10 @@ def _crow_timestamp_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
|
|
||||||
if num_of_rows > 0:
|
if num_of_rows > 0:
|
||||||
return list(map(_timestamp_converter, ctypes.cast(
|
return list(map(_timestamp_converter, ctypes.cast(
|
||||||
data, ctypes.POINTER(ctypes.c_longlong))[:abs(num_of_rows)]))
|
data, ctypes.POINTER(ctypes.c_long))[:abs(num_of_rows)]))
|
||||||
else:
|
else:
|
||||||
return list(map(_timestamp_converter, ctypes.cast(
|
return list(map(_timestamp_converter, ctypes.cast(
|
||||||
data, ctypes.POINTER(ctypes.c_longlong))[:abs(num_of_rows)]))
|
data, ctypes.POINTER(ctypes.c_long))[:abs(num_of_rows)]))
|
||||||
|
|
||||||
|
|
||||||
def _crow_bool_to_python(data, num_of_rows, nbytes=None, micro=False):
|
def _crow_bool_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
|
@ -56,6 +56,27 @@ def _crow_tinyint_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
data, ctypes.POINTER(ctypes.c_byte))[:abs(num_of_rows)]]
|
data, ctypes.POINTER(ctypes.c_byte))[:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
def _crow_tinyint_unsigned_to_python(
|
||||||
|
data,
|
||||||
|
num_of_rows,
|
||||||
|
nbytes=None,
|
||||||
|
micro=False):
|
||||||
|
"""Function to convert C tinyint row to python row
|
||||||
|
"""
|
||||||
|
if num_of_rows > 0:
|
||||||
|
return [
|
||||||
|
None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
|
data, ctypes.POINTER(
|
||||||
|
ctypes.c_ubyte))[
|
||||||
|
:abs(num_of_rows)]]
|
||||||
|
else:
|
||||||
|
return [
|
||||||
|
None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
|
data, ctypes.POINTER(
|
||||||
|
ctypes.c_ubyte))[
|
||||||
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
def _crow_smallint_to_python(data, num_of_rows, nbytes=None, micro=False):
|
def _crow_smallint_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
"""Function to convert C smallint row to python row
|
"""Function to convert C smallint row to python row
|
||||||
"""
|
"""
|
||||||
|
@ -73,6 +94,24 @@ def _crow_smallint_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
def _crow_smallint_unsigned_to_python(
|
||||||
|
data, num_of_rows, nbytes=None, micro=False):
|
||||||
|
"""Function to convert C smallint row to python row
|
||||||
|
"""
|
||||||
|
if num_of_rows > 0:
|
||||||
|
return [
|
||||||
|
None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
|
data, ctypes.POINTER(
|
||||||
|
ctypes.c_ushort))[
|
||||||
|
:abs(num_of_rows)]]
|
||||||
|
else:
|
||||||
|
return [
|
||||||
|
None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
|
data, ctypes.POINTER(
|
||||||
|
ctypes.c_ushort))[
|
||||||
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
def _crow_int_to_python(data, num_of_rows, nbytes=None, micro=False):
|
def _crow_int_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
"""Function to convert C int row to python row
|
"""Function to convert C int row to python row
|
||||||
"""
|
"""
|
||||||
|
@ -84,15 +123,53 @@ def _crow_int_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
data, ctypes.POINTER(ctypes.c_int))[:abs(num_of_rows)]]
|
data, ctypes.POINTER(ctypes.c_int))[:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
def _crow_int_unsigned_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
|
"""Function to convert C int row to python row
|
||||||
|
"""
|
||||||
|
if num_of_rows > 0:
|
||||||
|
return [
|
||||||
|
None if ele == FieldType.C_INT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
|
data, ctypes.POINTER(
|
||||||
|
ctypes.c_uint))[
|
||||||
|
:abs(num_of_rows)]]
|
||||||
|
else:
|
||||||
|
return [
|
||||||
|
None if ele == FieldType.C_INT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
|
data, ctypes.POINTER(
|
||||||
|
ctypes.c_uint))[
|
||||||
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
def _crow_bigint_to_python(data, num_of_rows, nbytes=None, micro=False):
|
def _crow_bigint_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
"""Function to convert C bigint row to python row
|
"""Function to convert C bigint row to python row
|
||||||
"""
|
"""
|
||||||
if num_of_rows > 0:
|
if num_of_rows > 0:
|
||||||
return [None if ele == FieldType.C_BIGINT_NULL else ele for ele in ctypes.cast(
|
return [None if ele == FieldType.C_BIGINT_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(ctypes.c_longlong))[:abs(num_of_rows)]]
|
data, ctypes.POINTER(ctypes.c_long))[:abs(num_of_rows)]]
|
||||||
else:
|
else:
|
||||||
return [None if ele == FieldType.C_BIGINT_NULL else ele for ele in ctypes.cast(
|
return [None if ele == FieldType.C_BIGINT_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(ctypes.c_longlong))[:abs(num_of_rows)]]
|
data, ctypes.POINTER(ctypes.c_long))[:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
def _crow_bigint_unsigned_to_python(
|
||||||
|
data,
|
||||||
|
num_of_rows,
|
||||||
|
nbytes=None,
|
||||||
|
micro=False):
|
||||||
|
"""Function to convert C bigint row to python row
|
||||||
|
"""
|
||||||
|
if num_of_rows > 0:
|
||||||
|
return [
|
||||||
|
None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
|
data, ctypes.POINTER(
|
||||||
|
ctypes.c_ulong))[
|
||||||
|
:abs(num_of_rows)]]
|
||||||
|
else:
|
||||||
|
return [
|
||||||
|
None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
|
data, ctypes.POINTER(
|
||||||
|
ctypes.c_ulong))[
|
||||||
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
def _crow_float_to_python(data, num_of_rows, nbytes=None, micro=False):
|
def _crow_float_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
|
@ -212,7 +289,11 @@ _CONVERT_FUNC = {
|
||||||
FieldType.C_DOUBLE: _crow_double_to_python,
|
FieldType.C_DOUBLE: _crow_double_to_python,
|
||||||
FieldType.C_BINARY: _crow_binary_to_python,
|
FieldType.C_BINARY: _crow_binary_to_python,
|
||||||
FieldType.C_TIMESTAMP: _crow_timestamp_to_python,
|
FieldType.C_TIMESTAMP: _crow_timestamp_to_python,
|
||||||
FieldType.C_NCHAR: _crow_nchar_to_python
|
FieldType.C_NCHAR: _crow_nchar_to_python,
|
||||||
|
FieldType.C_TINYINT_UNSIGNED: _crow_tinyint_unsigned_to_python,
|
||||||
|
FieldType.C_SMALLINT_UNSIGNED: _crow_smallint_unsigned_to_python,
|
||||||
|
FieldType.C_INT_UNSIGNED: _crow_int_unsigned_to_python,
|
||||||
|
FieldType.C_BIGINT_UNSIGNED: _crow_bigint_unsigned_to_python
|
||||||
}
|
}
|
||||||
|
|
||||||
_CONVERT_FUNC_BLOCK = {
|
_CONVERT_FUNC_BLOCK = {
|
||||||
|
@ -225,7 +306,11 @@ _CONVERT_FUNC_BLOCK = {
|
||||||
FieldType.C_DOUBLE: _crow_double_to_python,
|
FieldType.C_DOUBLE: _crow_double_to_python,
|
||||||
FieldType.C_BINARY: _crow_binary_to_python_block,
|
FieldType.C_BINARY: _crow_binary_to_python_block,
|
||||||
FieldType.C_TIMESTAMP: _crow_timestamp_to_python,
|
FieldType.C_TIMESTAMP: _crow_timestamp_to_python,
|
||||||
FieldType.C_NCHAR: _crow_nchar_to_python_block
|
FieldType.C_NCHAR: _crow_nchar_to_python_block,
|
||||||
|
FieldType.C_TINYINT_UNSIGNED: _crow_tinyint_unsigned_to_python,
|
||||||
|
FieldType.C_SMALLINT_UNSIGNED: _crow_smallint_unsigned_to_python,
|
||||||
|
FieldType.C_INT_UNSIGNED: _crow_int_unsigned_to_python,
|
||||||
|
FieldType.C_BIGINT_UNSIGNED: _crow_bigint_unsigned_to_python
|
||||||
}
|
}
|
||||||
|
|
||||||
# Corresponding TAOS_FIELD structure in C
|
# Corresponding TAOS_FIELD structure in C
|
||||||
|
|
|
@ -22,10 +22,10 @@ def _crow_timestamp_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
|
|
||||||
if num_of_rows > 0:
|
if num_of_rows > 0:
|
||||||
return list(map(_timestamp_converter, ctypes.cast(
|
return list(map(_timestamp_converter, ctypes.cast(
|
||||||
data, ctypes.POINTER(ctypes.c_longlong))[:abs(num_of_rows)]))
|
data, ctypes.POINTER(ctypes.c_long))[:abs(num_of_rows)]))
|
||||||
else:
|
else:
|
||||||
return list(map(_timestamp_converter, ctypes.cast(
|
return list(map(_timestamp_converter, ctypes.cast(
|
||||||
data, ctypes.POINTER(ctypes.c_longlong))[:abs(num_of_rows)]))
|
data, ctypes.POINTER(ctypes.c_long))[:abs(num_of_rows)]))
|
||||||
|
|
||||||
|
|
||||||
def _crow_bool_to_python(data, num_of_rows, nbytes=None, micro=False):
|
def _crow_bool_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
|
@ -56,6 +56,27 @@ def _crow_tinyint_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
data, ctypes.POINTER(ctypes.c_byte))[:abs(num_of_rows)]]
|
data, ctypes.POINTER(ctypes.c_byte))[:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
def _crow_tinyint_unsigned_to_python(
|
||||||
|
data,
|
||||||
|
num_of_rows,
|
||||||
|
nbytes=None,
|
||||||
|
micro=False):
|
||||||
|
"""Function to convert C tinyint row to python row
|
||||||
|
"""
|
||||||
|
if num_of_rows > 0:
|
||||||
|
return [
|
||||||
|
None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
|
data, ctypes.POINTER(
|
||||||
|
ctypes.c_ubyte))[
|
||||||
|
:abs(num_of_rows)]]
|
||||||
|
else:
|
||||||
|
return [
|
||||||
|
None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
|
data, ctypes.POINTER(
|
||||||
|
ctypes.c_ubyte))[
|
||||||
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
def _crow_smallint_to_python(data, num_of_rows, nbytes=None, micro=False):
|
def _crow_smallint_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
"""Function to convert C smallint row to python row
|
"""Function to convert C smallint row to python row
|
||||||
"""
|
"""
|
||||||
|
@ -73,6 +94,24 @@ def _crow_smallint_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
:abs(num_of_rows)]]
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
def _crow_smallint_unsigned_to_python(
|
||||||
|
data, num_of_rows, nbytes=None, micro=False):
|
||||||
|
"""Function to convert C smallint row to python row
|
||||||
|
"""
|
||||||
|
if num_of_rows > 0:
|
||||||
|
return [
|
||||||
|
None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
|
data, ctypes.POINTER(
|
||||||
|
ctypes.c_ushort))[
|
||||||
|
:abs(num_of_rows)]]
|
||||||
|
else:
|
||||||
|
return [
|
||||||
|
None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
|
data, ctypes.POINTER(
|
||||||
|
ctypes.c_ushort))[
|
||||||
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
def _crow_int_to_python(data, num_of_rows, nbytes=None, micro=False):
|
def _crow_int_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
"""Function to convert C int row to python row
|
"""Function to convert C int row to python row
|
||||||
"""
|
"""
|
||||||
|
@ -84,15 +123,53 @@ def _crow_int_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
data, ctypes.POINTER(ctypes.c_int))[:abs(num_of_rows)]]
|
data, ctypes.POINTER(ctypes.c_int))[:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
def _crow_int_unsigned_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
|
"""Function to convert C int row to python row
|
||||||
|
"""
|
||||||
|
if num_of_rows > 0:
|
||||||
|
return [
|
||||||
|
None if ele == FieldType.C_INT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
|
data, ctypes.POINTER(
|
||||||
|
ctypes.c_uint))[
|
||||||
|
:abs(num_of_rows)]]
|
||||||
|
else:
|
||||||
|
return [
|
||||||
|
None if ele == FieldType.C_INT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
|
data, ctypes.POINTER(
|
||||||
|
ctypes.c_uint))[
|
||||||
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
def _crow_bigint_to_python(data, num_of_rows, nbytes=None, micro=False):
|
def _crow_bigint_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
"""Function to convert C bigint row to python row
|
"""Function to convert C bigint row to python row
|
||||||
"""
|
"""
|
||||||
if num_of_rows > 0:
|
if num_of_rows > 0:
|
||||||
return [None if ele == FieldType.C_BIGINT_NULL else ele for ele in ctypes.cast(
|
return [None if ele == FieldType.C_BIGINT_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(ctypes.c_longlong))[:abs(num_of_rows)]]
|
data, ctypes.POINTER(ctypes.c_long))[:abs(num_of_rows)]]
|
||||||
else:
|
else:
|
||||||
return [None if ele == FieldType.C_BIGINT_NULL else ele for ele in ctypes.cast(
|
return [None if ele == FieldType.C_BIGINT_NULL else ele for ele in ctypes.cast(
|
||||||
data, ctypes.POINTER(ctypes.c_longlong))[:abs(num_of_rows)]]
|
data, ctypes.POINTER(ctypes.c_long))[:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
|
def _crow_bigint_unsigned_to_python(
|
||||||
|
data,
|
||||||
|
num_of_rows,
|
||||||
|
nbytes=None,
|
||||||
|
micro=False):
|
||||||
|
"""Function to convert C bigint row to python row
|
||||||
|
"""
|
||||||
|
if num_of_rows > 0:
|
||||||
|
return [
|
||||||
|
None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
|
data, ctypes.POINTER(
|
||||||
|
ctypes.c_ulong))[
|
||||||
|
:abs(num_of_rows)]]
|
||||||
|
else:
|
||||||
|
return [
|
||||||
|
None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele for ele in ctypes.cast(
|
||||||
|
data, ctypes.POINTER(
|
||||||
|
ctypes.c_ulong))[
|
||||||
|
:abs(num_of_rows)]]
|
||||||
|
|
||||||
|
|
||||||
def _crow_float_to_python(data, num_of_rows, nbytes=None, micro=False):
|
def _crow_float_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
|
@ -133,9 +210,7 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||||
"""Function to convert C nchar row to python row
|
"""Function to convert C nchar row to python row
|
||||||
"""
|
"""
|
||||||
assert(nbytes is not None)
|
assert(nbytes is not None)
|
||||||
|
|
||||||
res = []
|
res = []
|
||||||
|
|
||||||
for i in range(abs(num_of_rows)):
|
for i in range(abs(num_of_rows)):
|
||||||
try:
|
try:
|
||||||
if num_of_rows >= 0:
|
if num_of_rows >= 0:
|
||||||
|
@ -214,7 +289,11 @@ _CONVERT_FUNC = {
|
||||||
FieldType.C_DOUBLE: _crow_double_to_python,
|
FieldType.C_DOUBLE: _crow_double_to_python,
|
||||||
FieldType.C_BINARY: _crow_binary_to_python,
|
FieldType.C_BINARY: _crow_binary_to_python,
|
||||||
FieldType.C_TIMESTAMP: _crow_timestamp_to_python,
|
FieldType.C_TIMESTAMP: _crow_timestamp_to_python,
|
||||||
FieldType.C_NCHAR: _crow_nchar_to_python
|
FieldType.C_NCHAR: _crow_nchar_to_python,
|
||||||
|
FieldType.C_TINYINT_UNSIGNED: _crow_tinyint_unsigned_to_python,
|
||||||
|
FieldType.C_SMALLINT_UNSIGNED: _crow_smallint_unsigned_to_python,
|
||||||
|
FieldType.C_INT_UNSIGNED: _crow_int_unsigned_to_python,
|
||||||
|
FieldType.C_BIGINT_UNSIGNED: _crow_bigint_unsigned_to_python
|
||||||
}
|
}
|
||||||
|
|
||||||
_CONVERT_FUNC_BLOCK = {
|
_CONVERT_FUNC_BLOCK = {
|
||||||
|
@ -227,7 +306,11 @@ _CONVERT_FUNC_BLOCK = {
|
||||||
FieldType.C_DOUBLE: _crow_double_to_python,
|
FieldType.C_DOUBLE: _crow_double_to_python,
|
||||||
FieldType.C_BINARY: _crow_binary_to_python_block,
|
FieldType.C_BINARY: _crow_binary_to_python_block,
|
||||||
FieldType.C_TIMESTAMP: _crow_timestamp_to_python,
|
FieldType.C_TIMESTAMP: _crow_timestamp_to_python,
|
||||||
FieldType.C_NCHAR: _crow_nchar_to_python_block
|
FieldType.C_NCHAR: _crow_nchar_to_python_block,
|
||||||
|
FieldType.C_TINYINT_UNSIGNED: _crow_tinyint_unsigned_to_python,
|
||||||
|
FieldType.C_SMALLINT_UNSIGNED: _crow_smallint_unsigned_to_python,
|
||||||
|
FieldType.C_INT_UNSIGNED: _crow_int_unsigned_to_python,
|
||||||
|
FieldType.C_BIGINT_UNSIGNED: _crow_bigint_unsigned_to_python
|
||||||
}
|
}
|
||||||
|
|
||||||
# Corresponding TAOS_FIELD structure in C
|
# Corresponding TAOS_FIELD structure in C
|
||||||
|
|
Loading…
Reference in New Issue