Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
450bf068
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
450bf068
编写于
2月 20, 2021
作者:
sangshuduo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-2971] <feature>: make python connector support unsigned int. fix None determine.
上级
da32a257
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
206 addition
and
40 deletion
+206
-40
src/connector/python/linux/python2/taos/cinterface.py
src/connector/python/linux/python2/taos/cinterface.py
+8
-8
src/connector/python/linux/python3/taos/cinterface.py
src/connector/python/linux/python3/taos/cinterface.py
+8
-10
src/connector/python/osx/python3/taos/cinterface.py
src/connector/python/osx/python3/taos/cinterface.py
+8
-8
src/connector/python/windows/python2/taos/cinterface.py
src/connector/python/windows/python2/taos/cinterface.py
+91
-6
src/connector/python/windows/python3/taos/cinterface.py
src/connector/python/windows/python3/taos/cinterface.py
+91
-8
未找到文件。
src/connector/python/linux/python2/taos/cinterface.py
浏览文件 @
450bf068
...
...
@@ -67,13 +67,13 @@ def _crow_tinyint_unsigned_to_python(
return
[
None
if
ele
==
FieldType
.
C_TINYINT_UNSIGNED_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_byte
))[
ctypes
.
c_
u
byte
))[
:
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_byte
))[
ctypes
.
c_
u
byte
))[
:
abs
(
num_of_rows
)]]
...
...
@@ -102,13 +102,13 @@ def _crow_smallint_unsigned_to_python(
return
[
None
if
ele
==
FieldType
.
C_SMALLINT_UNSIGNED_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_short
))[
ctypes
.
c_
u
short
))[
:
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_short
))[
ctypes
.
c_
u
short
))[
:
abs
(
num_of_rows
)]]
...
...
@@ -130,13 +130,13 @@ def _crow_int_unsigned_to_python(data, num_of_rows, nbytes=None, micro=False):
return
[
None
if
ele
==
FieldType
.
C_INT_UNSIGNED_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_int
))[
ctypes
.
c_
u
int
))[
:
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_int
))[
ctypes
.
c_
u
int
))[
:
abs
(
num_of_rows
)]]
...
...
@@ -162,13 +162,13 @@ def _crow_bigint_unsigned_to_python(
return
[
None
if
ele
==
FieldType
.
C_BIGINT_UNSIGNED_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_long
))[
ctypes
.
c_
u
long
))[
:
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_long
))[
ctypes
.
c_
u
long
))[
:
abs
(
num_of_rows
)]]
...
...
src/connector/python/linux/python3/taos/cinterface.py
浏览文件 @
450bf068
...
...
@@ -67,13 +67,13 @@ def _crow_tinyint_unsigned_to_python(
return
[
None
if
ele
==
FieldType
.
C_TINYINT_UNSIGNED_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_byte
))[
ctypes
.
c_
u
byte
))[
:
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_byte
))[
ctypes
.
c_
u
byte
))[
:
abs
(
num_of_rows
)]]
...
...
@@ -102,13 +102,13 @@ def _crow_smallint_unsigned_to_python(
return
[
None
if
ele
==
FieldType
.
C_SMALLINT_UNSIGNED_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_short
))[
ctypes
.
c_
u
short
))[
:
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_short
))[
ctypes
.
c_
u
short
))[
:
abs
(
num_of_rows
)]]
...
...
@@ -130,13 +130,13 @@ def _crow_int_unsigned_to_python(data, num_of_rows, nbytes=None, micro=False):
return
[
None
if
ele
==
FieldType
.
C_INT_UNSIGNED_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_int
))[
ctypes
.
c_
u
int
))[
:
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_int
))[
ctypes
.
c_
u
int
))[
:
abs
(
num_of_rows
)]]
...
...
@@ -162,13 +162,13 @@ def _crow_bigint_unsigned_to_python(
return
[
None
if
ele
==
FieldType
.
C_BIGINT_UNSIGNED_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_long
))[
ctypes
.
c_
u
long
))[
:
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_long
))[
ctypes
.
c_
u
long
))[
:
abs
(
num_of_rows
)]]
...
...
@@ -523,7 +523,6 @@ class CTaosInterface(object):
for
i
in
range
(
len
(
fields
)):
data
=
ctypes
.
cast
(
pblock
,
ctypes
.
POINTER
(
ctypes
.
c_void_p
))[
i
]
if
fields
[
i
][
'type'
]
not
in
_CONVERT_FUNC_BLOCK
:
print
(
"CBD cinterface.py LN526"
)
raise
DatabaseError
(
"Invalid data type returned from database"
)
blocks
[
i
]
=
_CONVERT_FUNC_BLOCK
[
fields
[
i
][
'type'
]](
data
,
num_of_rows
,
fieldLen
[
i
],
isMicro
)
...
...
@@ -548,7 +547,6 @@ class CTaosInterface(object):
for
i
in
range
(
len
(
fields
)):
data
=
ctypes
.
cast
(
pblock
,
ctypes
.
POINTER
(
ctypes
.
c_void_p
))[
i
]
if
fields
[
i
][
'type'
]
not
in
_CONVERT_FUNC
:
print
(
"CBD cinterface.py LN551"
)
raise
DatabaseError
(
"Invalid data type returned from database"
)
if
data
is
None
:
...
...
src/connector/python/osx/python3/taos/cinterface.py
浏览文件 @
450bf068
...
...
@@ -67,13 +67,13 @@ def _crow_tinyint_unsigned_to_python(
return
[
None
if
ele
==
FieldType
.
C_TINYINT_UNSIGNED_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_byte
))[
ctypes
.
c_
u
byte
))[
:
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_byte
))[
ctypes
.
c_
u
byte
))[
:
abs
(
num_of_rows
)]]
...
...
@@ -102,13 +102,13 @@ def _crow_smallint_unsigned_to_python(
return
[
None
if
ele
==
FieldType
.
C_SMALLINT_UNSIGNED_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_short
))[
ctypes
.
c_
u
short
))[
:
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_short
))[
ctypes
.
c_
u
short
))[
:
abs
(
num_of_rows
)]]
...
...
@@ -130,13 +130,13 @@ def _crow_int_unsigned_to_python(data, num_of_rows, nbytes=None, micro=False):
return
[
None
if
ele
==
FieldType
.
C_INT_UNSIGNED_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_int
))[
ctypes
.
c_
u
int
))[
:
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_int
))[
ctypes
.
c_
u
int
))[
:
abs
(
num_of_rows
)]]
...
...
@@ -162,13 +162,13 @@ def _crow_bigint_unsigned_to_python(
return
[
None
if
ele
==
FieldType
.
C_BIGINT_UNSIGNED_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_long
))[
ctypes
.
c_
u
long
))[
:
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_long
))[
ctypes
.
c_
u
long
))[
:
abs
(
num_of_rows
)]]
...
...
src/connector/python/windows/python2/taos/cinterface.py
浏览文件 @
450bf068
...
...
@@ -22,10 +22,10 @@ def _crow_timestamp_to_python(data, num_of_rows, nbytes=None, micro=False):
if
num_of_rows
>
0
:
return
list
(
map
(
_timestamp_converter
,
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_long
long
))[:
abs
(
num_of_rows
)]))
data
,
ctypes
.
POINTER
(
ctypes
.
c_long
))[:
abs
(
num_of_rows
)]))
else
:
return
list
(
map
(
_timestamp_converter
,
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_long
long
))[:
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
):
...
...
@@ -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
)]]
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
):
"""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
)]]
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
):
"""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
)]]
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
):
"""Function to convert C bigint row to python row
"""
if
num_of_rows
>
0
:
return
[
None
if
ele
==
FieldType
.
C_BIGINT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_long
long
))[:
abs
(
num_of_rows
)]]
data
,
ctypes
.
POINTER
(
ctypes
.
c_long
))[:
abs
(
num_of_rows
)]]
else
:
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
):
...
...
@@ -212,7 +289,11 @@ _CONVERT_FUNC = {
FieldType
.
C_DOUBLE
:
_crow_double_to_python
,
FieldType
.
C_BINARY
:
_crow_binary_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
=
{
...
...
@@ -225,7 +306,11 @@ _CONVERT_FUNC_BLOCK = {
FieldType
.
C_DOUBLE
:
_crow_double_to_python
,
FieldType
.
C_BINARY
:
_crow_binary_to_python_block
,
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
...
...
src/connector/python/windows/python3/taos/cinterface.py
浏览文件 @
450bf068
...
...
@@ -22,10 +22,10 @@ def _crow_timestamp_to_python(data, num_of_rows, nbytes=None, micro=False):
if
num_of_rows
>
0
:
return
list
(
map
(
_timestamp_converter
,
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_long
long
))[:
abs
(
num_of_rows
)]))
data
,
ctypes
.
POINTER
(
ctypes
.
c_long
))[:
abs
(
num_of_rows
)]))
else
:
return
list
(
map
(
_timestamp_converter
,
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_long
long
))[:
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
):
...
...
@@ -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
)]]
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
):
"""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
)]]
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
):
"""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
)]]
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
):
"""Function to convert C bigint row to python row
"""
if
num_of_rows
>
0
:
return
[
None
if
ele
==
FieldType
.
C_BIGINT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_long
long
))[:
abs
(
num_of_rows
)]]
data
,
ctypes
.
POINTER
(
ctypes
.
c_long
))[:
abs
(
num_of_rows
)]]
else
:
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
):
...
...
@@ -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
"""
assert
(
nbytes
is
not
None
)
res
=
[]
for
i
in
range
(
abs
(
num_of_rows
)):
try
:
if
num_of_rows
>=
0
:
...
...
@@ -214,7 +289,11 @@ _CONVERT_FUNC = {
FieldType
.
C_DOUBLE
:
_crow_double_to_python
,
FieldType
.
C_BINARY
:
_crow_binary_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
=
{
...
...
@@ -227,7 +306,11 @@ _CONVERT_FUNC_BLOCK = {
FieldType
.
C_DOUBLE
:
_crow_double_to_python
,
FieldType
.
C_BINARY
:
_crow_binary_to_python_block
,
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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录