Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
8904a046
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8904a046
编写于
2月 18, 2021
作者:
sangshuduo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-2971] feature: make python connector support unsigned type.
上级
d27fb227
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
270 addition
and
30 deletion
+270
-30
src/connector/python/linux/python2/setup.py
src/connector/python/linux/python2/setup.py
+1
-1
src/connector/python/linux/python2/taos/__init__.py
src/connector/python/linux/python2/taos/__init__.py
+1
-2
src/connector/python/linux/python2/taos/cinterface.py
src/connector/python/linux/python2/taos/cinterface.py
+47
-6
src/connector/python/linux/python2/taos/constants.py
src/connector/python/linux/python2/taos/constants.py
+8
-0
src/connector/python/linux/python2/taos/cursor.py
src/connector/python/linux/python2/taos/cursor.py
+16
-1
src/connector/python/linux/python3/setup.py
src/connector/python/linux/python3/setup.py
+1
-1
src/connector/python/linux/python3/taos/__init__.py
src/connector/python/linux/python3/taos/__init__.py
+0
-1
src/connector/python/linux/python3/taos/cinterface.py
src/connector/python/linux/python3/taos/cinterface.py
+45
-5
src/connector/python/linux/python3/taos/constants.py
src/connector/python/linux/python3/taos/constants.py
+8
-0
src/connector/python/linux/python3/taos/cursor.py
src/connector/python/linux/python3/taos/cursor.py
+16
-1
src/connector/python/osx/python3/setup.py
src/connector/python/osx/python3/setup.py
+1
-1
src/connector/python/osx/python3/taos/__init__.py
src/connector/python/osx/python3/taos/__init__.py
+0
-1
src/connector/python/osx/python3/taos/cinterface.py
src/connector/python/osx/python3/taos/cinterface.py
+45
-5
src/connector/python/osx/python3/taos/constants.py
src/connector/python/osx/python3/taos/constants.py
+8
-0
src/connector/python/osx/python3/taos/cursor.py
src/connector/python/osx/python3/taos/cursor.py
+16
-1
src/connector/python/windows/python2/taos/__init__.py
src/connector/python/windows/python2/taos/__init__.py
+1
-2
src/connector/python/windows/python3/taos/__init__.py
src/connector/python/windows/python3/taos/__init__.py
+1
-2
tests/pytest/insert/basic_unsigned.py
tests/pytest/insert/basic_unsigned.py
+55
-0
未找到文件。
src/connector/python/linux/python2/setup.py
浏览文件 @
8904a046
...
...
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools
.
setup
(
name
=
"taos"
,
version
=
"2.0.
5
"
,
version
=
"2.0.
6
"
,
author
=
"Taosdata Inc."
,
author_email
=
"support@taosdata.com"
,
description
=
"TDengine python client package"
,
...
...
src/connector/python/linux/python2/taos/__init__.py
浏览文件 @
8904a046
...
...
@@ -3,7 +3,6 @@ from .connection import TDengineConnection
from
.cursor
import
TDengineCursor
# Globals
apilevel
=
'2.0.3'
threadsafety
=
0
paramstyle
=
'pyformat'
...
...
@@ -21,4 +20,4 @@ def connect(*args, **kwargs):
@rtype: TDengineConnector
"""
return
TDengineConnection
(
*
args
,
**
kwargs
)
\ No newline at end of file
return
TDengineConnection
(
*
args
,
**
kwargs
)
src/connector/python/linux/python2/taos/cinterface.py
浏览文件 @
8904a046
...
...
@@ -37,7 +37,15 @@ def _crow_tinyint_to_python(data, num_of_rows, nbytes=None, micro=False):
return
[
None
if
ele
==
FieldType
.
C_TINYINT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_byte
))[:
abs
(
num_of_rows
)]
]
else
:
return
[
None
if
ele
==
FieldType
.
C_TINYINT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
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_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
))[:
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
"""
...
...
@@ -46,6 +54,14 @@ def _crow_smallint_to_python(data, num_of_rows, nbytes=None, micro=False):
else
:
return
[
None
if
ele
==
FieldType
.
C_SMALLINT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_short
))[:
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_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
))[:
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
"""
...
...
@@ -54,6 +70,14 @@ def _crow_int_to_python(data, num_of_rows, nbytes=None, micro=False):
else
:
return
[
None
if
ele
==
FieldType
.
C_INT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
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_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
))[:
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
"""
...
...
@@ -62,6 +86,14 @@ def _crow_bigint_to_python(data, num_of_rows, nbytes=None, micro=False):
else
:
return
[
None
if
ele
==
FieldType
.
C_BIGINT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
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_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
))[:
abs
(
num_of_rows
)]
]
def
_crow_float_to_python
(
data
,
num_of_rows
,
nbytes
=
None
,
micro
=
False
):
"""Function to convert C float row to python row
"""
...
...
@@ -156,8 +188,12 @@ _CONVERT_FUNC = {
FieldType
.
C_FLOAT
:
_crow_float_to_python
,
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_TIMESTAMP
:
_crow_timestamp_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
=
{
...
...
@@ -169,8 +205,12 @@ _CONVERT_FUNC_BLOCK = {
FieldType
.
C_FLOAT
:
_crow_float_to_python
,
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_TIMESTAMP
:
_crow_timestamp_to_python
,
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
...
...
@@ -298,7 +338,7 @@ class CTaosInterface(object):
raise
AttributeError
(
"sql is expected as a string"
)
# finally:
# CTaosInterface.libtaos.close(connection)
@
staticmethod
def
affectedRows
(
result
):
"""The affected rows after runing query
...
...
@@ -392,6 +432,7 @@ class CTaosInterface(object):
else
:
return
None
,
0
return
blocks
,
abs
(
num_of_rows
)
@
staticmethod
def
freeResult
(
result
):
CTaosInterface
.
libtaos
.
taos_free_result
(
result
)
...
...
src/connector/python/linux/python2/taos/constants.py
浏览文件 @
8904a046
...
...
@@ -18,13 +18,21 @@ class FieldType(object):
C_BINARY
=
8
C_TIMESTAMP
=
9
C_NCHAR
=
10
C_TINYINT_UNSIGNED
=
12
C_SMALLINT_UNSIGNED
=
13
C_INT_UNSIGNED
=
14
C_BIGINT_UNSIGNED
=
15
# NULL value definition
# NOTE: These values should change according to C definition in tsdb.h
C_BOOL_NULL
=
0x02
C_TINYINT_NULL
=
-
128
C_TINYINT_UNSIGNED_NULL
=
255
C_SMALLINT_NULL
=
-
32768
C_SMALLINT_UNSIGNED_NULL
=
65535
C_INT_NULL
=
-
2147483648
C_INT_UNSIGNED_NULL
=
4294967295
C_BIGINT_NULL
=
-
9223372036854775808
C_BIGINT_UNSIGNED_NULL
=
18446744073709551615
C_FLOAT_NULL
=
float
(
'nan'
)
C_DOUBLE_NULL
=
float
(
'nan'
)
C_BINARY_NULL
=
bytearray
([
int
(
'0xff'
,
16
)])
...
...
src/connector/python/linux/python2/taos/cursor.py
浏览文件 @
8904a046
...
...
@@ -158,11 +158,26 @@ class TDengineCursor(object):
if
(
dataType
.
upper
()
==
"TINYINT"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_TINYINT
):
return
True
if
(
dataType
.
upper
()
==
"TINYINT UNSIGNED"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_TINYINT_UNSIGNED
):
return
True
if
(
dataType
.
upper
()
==
"SMALLINT"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_SMALLINT
):
return
True
if
(
dataType
.
upper
()
==
"SMALLINT UNSIGNED"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_SMALLINT_UNSIGNED
):
return
True
if
(
dataType
.
upper
()
==
"INT"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_INT
):
return
True
if
(
dataType
.
upper
()
==
"INT UNSIGNED"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_INT_UNSIGNED
):
return
True
if
(
dataType
.
upper
()
==
"BIGINT"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_INT
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_BIGINT
):
return
True
if
(
dataType
.
upper
()
==
"BIGINT UNSIGNED"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_BIGINT_UNSIGNED
):
return
True
if
(
dataType
.
upper
()
==
"FLOAT"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_FLOAT
):
...
...
src/connector/python/linux/python3/setup.py
浏览文件 @
8904a046
...
...
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools
.
setup
(
name
=
"taos"
,
version
=
"2.0.
4
"
,
version
=
"2.0.
5
"
,
author
=
"Taosdata Inc."
,
author_email
=
"support@taosdata.com"
,
description
=
"TDengine python client package"
,
...
...
src/connector/python/linux/python3/taos/__init__.py
浏览文件 @
8904a046
...
...
@@ -3,7 +3,6 @@ from .connection import TDengineConnection
from
.cursor
import
TDengineCursor
# Globals
apilevel
=
'2.0.3'
threadsafety
=
0
paramstyle
=
'pyformat'
...
...
src/connector/python/linux/python3/taos/cinterface.py
浏览文件 @
8904a046
...
...
@@ -37,7 +37,15 @@ def _crow_tinyint_to_python(data, num_of_rows, nbytes=None, micro=False):
return
[
None
if
ele
==
FieldType
.
C_TINYINT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_byte
))[:
abs
(
num_of_rows
)]
]
else
:
return
[
None
if
ele
==
FieldType
.
C_TINYINT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
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_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
))[:
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
"""
...
...
@@ -46,6 +54,14 @@ def _crow_smallint_to_python(data, num_of_rows, nbytes=None, micro=False):
else
:
return
[
None
if
ele
==
FieldType
.
C_SMALLINT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_short
))[:
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_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
))[:
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
"""
...
...
@@ -54,6 +70,14 @@ def _crow_int_to_python(data, num_of_rows, nbytes=None, micro=False):
else
:
return
[
None
if
ele
==
FieldType
.
C_INT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
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_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
))[:
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
"""
...
...
@@ -62,6 +86,14 @@ def _crow_bigint_to_python(data, num_of_rows, nbytes=None, micro=False):
else
:
return
[
None
if
ele
==
FieldType
.
C_BIGINT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
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_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
))[:
abs
(
num_of_rows
)]
]
def
_crow_float_to_python
(
data
,
num_of_rows
,
nbytes
=
None
,
micro
=
False
):
"""Function to convert C float row to python row
"""
...
...
@@ -156,8 +188,12 @@ _CONVERT_FUNC = {
FieldType
.
C_FLOAT
:
_crow_float_to_python
,
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_TIMESTAMP
:
_crow_timestamp_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
=
{
...
...
@@ -169,8 +205,12 @@ _CONVERT_FUNC_BLOCK = {
FieldType
.
C_FLOAT
:
_crow_float_to_python
,
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_TIMESTAMP
:
_crow_timestamp_to_python
,
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/linux/python3/taos/constants.py
浏览文件 @
8904a046
...
...
@@ -18,13 +18,21 @@ class FieldType(object):
C_BINARY
=
8
C_TIMESTAMP
=
9
C_NCHAR
=
10
C_TINYINT_UNSIGNED
=
12
C_SMALLINT_UNSIGNED
=
13
C_INT_UNSIGNED
=
14
C_BIGINT_UNSIGNED
=
15
# NULL value definition
# NOTE: These values should change according to C definition in tsdb.h
C_BOOL_NULL
=
0x02
C_TINYINT_NULL
=
-
128
C_TINYINT_UNSIGNED_NULL
=
255
C_SMALLINT_NULL
=
-
32768
C_SMALLINT_UNSIGNED_NULL
=
65535
C_INT_NULL
=
-
2147483648
C_INT_UNSIGNED_NULL
=
4294967295
C_BIGINT_NULL
=
-
9223372036854775808
C_BIGINT_UNSIGNED_NULL
=
18446744073709551615
C_FLOAT_NULL
=
float
(
'nan'
)
C_DOUBLE_NULL
=
float
(
'nan'
)
C_BINARY_NULL
=
bytearray
([
int
(
'0xff'
,
16
)])
...
...
src/connector/python/linux/python3/taos/cursor.py
浏览文件 @
8904a046
...
...
@@ -168,11 +168,26 @@ class TDengineCursor(object):
if
(
dataType
.
upper
()
==
"TINYINT"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_TINYINT
):
return
True
if
(
dataType
.
upper
()
==
"TINYINT UNSIGNED"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_TINYINT_UNSIGNED
):
return
True
if
(
dataType
.
upper
()
==
"SMALLINT"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_SMALLINT
):
return
True
if
(
dataType
.
upper
()
==
"SMALLINT UNSIGNED"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_SMALLINT_UNSIGNED
):
return
True
if
(
dataType
.
upper
()
==
"INT"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_INT
):
return
True
if
(
dataType
.
upper
()
==
"INT UNSIGNED"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_INT_UNSIGNED
):
return
True
if
(
dataType
.
upper
()
==
"BIGINT"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_INT
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_BIGINT
):
return
True
if
(
dataType
.
upper
()
==
"BIGINT UNSIGNED"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_BIGINT_UNSIGNED
):
return
True
if
(
dataType
.
upper
()
==
"FLOAT"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_FLOAT
):
...
...
src/connector/python/osx/python3/setup.py
浏览文件 @
8904a046
...
...
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools
.
setup
(
name
=
"taos"
,
version
=
"2.0.
4
"
,
version
=
"2.0.
5
"
,
author
=
"Taosdata Inc."
,
author_email
=
"support@taosdata.com"
,
description
=
"TDengine python client package"
,
...
...
src/connector/python/osx/python3/taos/__init__.py
浏览文件 @
8904a046
...
...
@@ -3,7 +3,6 @@ from .connection import TDengineConnection
from
.cursor
import
TDengineCursor
# Globals
apilevel
=
'2.0.4'
threadsafety
=
0
paramstyle
=
'pyformat'
...
...
src/connector/python/osx/python3/taos/cinterface.py
浏览文件 @
8904a046
...
...
@@ -37,7 +37,15 @@ def _crow_tinyint_to_python(data, num_of_rows, nbytes=None, micro=False):
return
[
None
if
ele
==
FieldType
.
C_TINYINT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_byte
))[:
abs
(
num_of_rows
)]
]
else
:
return
[
None
if
ele
==
FieldType
.
C_TINYINT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
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_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
))[:
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
"""
...
...
@@ -46,6 +54,14 @@ def _crow_smallint_to_python(data, num_of_rows, nbytes=None, micro=False):
else
:
return
[
None
if
ele
==
FieldType
.
C_SMALLINT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
data
,
ctypes
.
POINTER
(
ctypes
.
c_short
))[:
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_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
))[:
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
"""
...
...
@@ -54,6 +70,14 @@ def _crow_int_to_python(data, num_of_rows, nbytes=None, micro=False):
else
:
return
[
None
if
ele
==
FieldType
.
C_INT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
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_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
))[:
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
"""
...
...
@@ -62,6 +86,14 @@ def _crow_bigint_to_python(data, num_of_rows, nbytes=None, micro=False):
else
:
return
[
None
if
ele
==
FieldType
.
C_BIGINT_NULL
else
ele
for
ele
in
ctypes
.
cast
(
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_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
))[:
abs
(
num_of_rows
)]
]
def
_crow_float_to_python
(
data
,
num_of_rows
,
nbytes
=
None
,
micro
=
False
):
"""Function to convert C float row to python row
"""
...
...
@@ -156,8 +188,12 @@ _CONVERT_FUNC = {
FieldType
.
C_FLOAT
:
_crow_float_to_python
,
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_TIMESTAMP
:
_crow_timestamp_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
=
{
...
...
@@ -169,8 +205,12 @@ _CONVERT_FUNC_BLOCK = {
FieldType
.
C_FLOAT
:
_crow_float_to_python
,
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_TIMESTAMP
:
_crow_timestamp_to_python
,
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/osx/python3/taos/constants.py
浏览文件 @
8904a046
...
...
@@ -18,13 +18,21 @@ class FieldType(object):
C_BINARY
=
8
C_TIMESTAMP
=
9
C_NCHAR
=
10
C_TINYINT_UNSIGNED
=
12
C_SMALLINT_UNSIGNED
=
13
C_INT_UNSIGNED
=
14
C_BIGINT_UNSIGNED
=
15
# NULL value definition
# NOTE: These values should change according to C definition in tsdb.h
C_BOOL_NULL
=
0x02
C_TINYINT_NULL
=
-
128
C_TINYINT_UNSIGNED_NULL
=
255
C_SMALLINT_NULL
=
-
32768
C_SMALLINT_UNSIGNED_NULL
=
65535
C_INT_NULL
=
-
2147483648
C_INT_UNSIGNED_NULL
=
4294967295
C_BIGINT_NULL
=
-
9223372036854775808
C_BIGINT_UNSIGNED_NULL
=
18446744073709551615
C_FLOAT_NULL
=
float
(
'nan'
)
C_DOUBLE_NULL
=
float
(
'nan'
)
C_BINARY_NULL
=
bytearray
([
int
(
'0xff'
,
16
)])
...
...
src/connector/python/osx/python3/taos/cursor.py
浏览文件 @
8904a046
...
...
@@ -168,11 +168,26 @@ class TDengineCursor(object):
if
(
dataType
.
upper
()
==
"TINYINT"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_TINYINT
):
return
True
if
(
dataType
.
upper
()
==
"TINYINT UNSIGNED"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_TINYINT_UNSIGNED
):
return
True
if
(
dataType
.
upper
()
==
"SMALLINT"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_SMALLINT
):
return
True
if
(
dataType
.
upper
()
==
"SMALLINT UNSIGNED"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_SMALLINT_UNSIGNED
):
return
True
if
(
dataType
.
upper
()
==
"INT"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_INT
):
return
True
if
(
dataType
.
upper
()
==
"INT UNSIGNED"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_INT_UNSIGNED
):
return
True
if
(
dataType
.
upper
()
==
"BIGINT"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_INT
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_BIGINT
):
return
True
if
(
dataType
.
upper
()
==
"BIGINT UNSIGNED"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_BIGINT_UNSIGNED
):
return
True
if
(
dataType
.
upper
()
==
"FLOAT"
):
if
(
self
.
_description
[
col
][
1
]
==
FieldType
.
C_FLOAT
):
...
...
src/connector/python/windows/python2/taos/__init__.py
浏览文件 @
8904a046
...
...
@@ -3,7 +3,6 @@ from .connection import TDengineConnection
from
.cursor
import
TDengineCursor
# Globals
apilevel
=
'2.0.3'
threadsafety
=
0
paramstyle
=
'pyformat'
...
...
@@ -21,4 +20,4 @@ def connect(*args, **kwargs):
@rtype: TDengineConnector
"""
return
TDengineConnection
(
*
args
,
**
kwargs
)
\ No newline at end of file
return
TDengineConnection
(
*
args
,
**
kwargs
)
src/connector/python/windows/python3/taos/__init__.py
浏览文件 @
8904a046
...
...
@@ -3,7 +3,6 @@ from .connection import TDengineConnection
from
.cursor
import
TDengineCursor
# Globals
apilevel
=
'2.0.3'
threadsafety
=
0
paramstyle
=
'pyformat'
...
...
@@ -21,4 +20,4 @@ def connect(*args, **kwargs):
@rtype: TDengineConnector
"""
return
TDengineConnection
(
*
args
,
**
kwargs
)
\ No newline at end of file
return
TDengineConnection
(
*
args
,
**
kwargs
)
tests/pytest/insert/basic_unsigned.py
0 → 100644
浏览文件 @
8904a046
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
def
run
(
self
):
tdSql
.
prepare
()
ret
=
tdSql
.
execute
(
'create table tb (ts timestamp, speed int unsigned)'
)
insertRows
=
10
tdLog
.
info
(
"insert %d rows"
%
(
insertRows
))
for
i
in
range
(
0
,
insertRows
):
ret
=
tdSql
.
execute
(
'insert into tb values (now + %dm, %d)'
%
(
i
,
i
))
tdLog
.
info
(
"insert earlier data"
)
tdSql
.
execute
(
'insert into tb values (now - 5m , 10)'
)
tdSql
.
execute
(
'insert into tb values (now - 6m , 10)'
)
tdSql
.
execute
(
'insert into tb values (now - 7m , 10)'
)
tdSql
.
execute
(
'insert into tb values (now - 8m , 4294967294)'
)
tdSql
.
error
(
'insert into tb values (now - 9m, -1)'
)
tdSql
.
error
(
'insert into tb values (now - 9m, 4294967295)'
)
tdSql
.
query
(
"select * from tb"
)
tdSql
.
checkRows
(
insertRows
+
4
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录