Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2f7ff301
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看板
提交
2f7ff301
编写于
5月 31, 2022
作者:
haoranc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test:add testcase of python connector using Statement API
上级
c0ecf2c1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
374 addition
and
6 deletion
+374
-6
tests/system-test/1-insert/test_stmt_insert_query_ex.py
tests/system-test/1-insert/test_stmt_insert_query_ex.py
+16
-5
tests/system-test/1-insert/test_stmt_muti_insert_query.py
tests/system-test/1-insert/test_stmt_muti_insert_query.py
+181
-0
tests/system-test/1-insert/test_stmt_set_tbname_tag.py
tests/system-test/1-insert/test_stmt_set_tbname_tag.py
+176
-0
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+1
-1
未找到文件。
tests/system-test/1-insert/test_stmt_insert_query.py
→
tests/system-test/1-insert/test_stmt_insert_query
_ex
.py
浏览文件 @
2f7ff301
...
...
@@ -230,9 +230,20 @@ class TDTestCase:
querystmt1
.
execute
()
result1
=
querystmt1
.
use_result
()
rows1
=
result1
.
fetch_all
()
assert
str
(
rows1
[
0
][
0
])
==
"2021-07-21 17:56:32.589111"
assert
rows1
[
0
][
10
]
==
3
assert
rows1
[
1
][
10
]
==
4
print
(
rows1
)
querystmt2
=
conn
.
statement
(
"select abs(?) from log where bu < ?"
)
queryparam2
=
new_bind_params
(
2
)
print
(
type
(
queryparam1
))
queryparam2
[
0
].
int
(
5
)
queryparam2
[
1
].
int
(
5
)
querystmt2
.
bind_param
(
queryparam2
)
querystmt2
.
execute
()
result2
=
querystmt2
.
use_result
()
rows2
=
result2
.
fetch_all
()
print
(
rows2
)
# assert str(rows1[0][0]) == "2021-07-21 17:56:32.589111"
# assert rows1[0][10] == 3
# assert rows1[1][10] == 4
# conn.execute("drop database if exists %s" % dbname)
conn
.
close
()
...
...
@@ -248,8 +259,8 @@ class TDTestCase:
host
=
"localhost"
connectstmt
=
self
.
newcon
(
host
,
config
)
self
.
test_stmt_insert_multi
(
connectstmt
)
#
connectstmt=self.newcon(host,config)
#
self.test_stmt_set_tbname_tag(connectstmt)
connectstmt
=
self
.
newcon
(
host
,
config
)
self
.
test_stmt_set_tbname_tag
(
connectstmt
)
return
...
...
tests/system-test/1-insert/test_stmt_muti_insert_query.py
0 → 100644
浏览文件 @
2f7ff301
###################################################################
# 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
import
os
import
threading
as
thd
import
multiprocessing
as
mp
from
numpy.lib.function_base
import
insert
import
taos
from
taos
import
*
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
import
datetime
as
dt
from
datetime
import
datetime
from
ctypes
import
*
import
time
# constant define
WAITS
=
5
# wait seconds
class
TDTestCase
:
#
# --------------- main frame -------------------
def
caseDescription
(
self
):
'''
limit and offset keyword function test cases;
case1: limit offset base function test
case2: offset return valid
'''
return
def
getBuildPath
(
self
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
if
(
"community"
in
selfPath
):
projPath
=
selfPath
[:
selfPath
.
find
(
"community"
)]
else
:
projPath
=
selfPath
[:
selfPath
.
find
(
"tests"
)]
for
root
,
dirs
,
files
in
os
.
walk
(
projPath
):
if
(
"taosd"
in
files
):
rootRealPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
root
))
if
(
"packaging"
not
in
rootRealPath
):
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
break
return
buildPath
# init
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
# tdSql.prepare()
# self.create_tables();
self
.
ts
=
1500000000000
# stop
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
# --------------- case -------------------
def
newcon
(
self
,
host
,
cfg
):
user
=
"root"
password
=
"taosdata"
port
=
6030
con
=
taos
.
connect
(
host
=
host
,
user
=
user
,
password
=
password
,
config
=
cfg
,
port
=
port
)
print
(
con
)
return
con
def
test_stmt_insert_multi
(
self
,
conn
):
# type: (TaosConnection) -> None
dbname
=
"pytest_taos_stmt_multi"
try
:
conn
.
execute
(
"drop database if exists %s"
%
dbname
)
conn
.
execute
(
"create database if not exists %s"
%
dbname
)
conn
.
select_db
(
dbname
)
conn
.
execute
(
"create table if not exists log(ts timestamp, bo bool, nil tinyint, ti tinyint, si smallint, ii int,
\
bi bigint, tu tinyint unsigned, su smallint unsigned, iu int unsigned, bu bigint unsigned,
\
ff float, dd double, bb binary(100), nn nchar(100), tt timestamp)"
,
)
# conn.load_table_info("log")
start
=
datetime
.
now
()
stmt
=
conn
.
statement
(
"insert into log values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
)
params
=
new_multi_binds
(
16
)
params
[
0
].
timestamp
((
1626861392589
,
1626861392590
,
1626861392591
))
params
[
1
].
bool
((
True
,
None
,
False
))
params
[
2
].
tinyint
([
-
128
,
-
128
,
None
])
# -128 is tinyint null
params
[
3
].
tinyint
([
0
,
127
,
None
])
params
[
4
].
smallint
([
3
,
None
,
2
])
params
[
5
].
int
([
3
,
4
,
None
])
params
[
6
].
bigint
([
3
,
4
,
None
])
params
[
7
].
tinyint_unsigned
([
3
,
4
,
None
])
params
[
8
].
smallint_unsigned
([
3
,
4
,
None
])
params
[
9
].
int_unsigned
([
3
,
4
,
None
])
params
[
10
].
bigint_unsigned
([
3
,
4
,
None
])
params
[
11
].
float
([
3
,
None
,
1
])
params
[
12
].
double
([
3
,
None
,
1.2
])
params
[
13
].
binary
([
"abc"
,
"dddafadfadfadfadfa"
,
None
])
params
[
14
].
nchar
([
"涛思数据"
,
None
,
"a long string with 中文字符"
])
params
[
15
].
timestamp
([
None
,
None
,
1626861392591
])
# print(type(stmt))
stmt
.
bind_param_batch
(
params
)
stmt
.
execute
()
end
=
datetime
.
now
()
print
(
"elapsed time: "
,
end
-
start
)
assert
stmt
.
affected_rows
==
3
#query
querystmt
=
conn
.
statement
(
"select ?,bu from log"
)
queryparam
=
new_bind_params
(
1
)
print
(
type
(
queryparam
))
queryparam
[
0
].
binary
(
"ts"
)
querystmt
.
bind_param
(
queryparam
)
querystmt
.
execute
()
result
=
querystmt
.
use_result
()
# rows=result.fetch_all()
# print( querystmt.use_result())
# result = conn.query("select * from log")
rows
=
result
.
fetch_all
()
# rows=result.fetch_all()
print
(
rows
)
assert
rows
[
1
][
0
]
==
"ts"
assert
rows
[
0
][
1
]
==
3
#query
querystmt1
=
conn
.
statement
(
"select * from log where bu < ?"
)
queryparam1
=
new_bind_params
(
1
)
print
(
type
(
queryparam1
))
queryparam1
[
0
].
int
(
4
)
querystmt1
.
bind_param
(
queryparam1
)
querystmt1
.
execute
()
result1
=
querystmt1
.
use_result
()
rows1
=
result1
.
fetch_all
()
print
(
rows1
)
assert
str
(
rows1
[
0
][
0
])
==
"2021-07-21 17:56:32.589000"
assert
rows1
[
0
][
10
]
==
3
stmt
.
close
()
# conn.execute("drop database if exists %s" % dbname)
conn
.
close
()
except
Exception
as
err
:
# conn.execute("drop database if exists %s" % dbname)
conn
.
close
()
raise
err
def
run
(
self
):
buildPath
=
self
.
getBuildPath
()
config
=
buildPath
+
"../sim/dnode1/cfg/"
host
=
"localhost"
connectstmt
=
self
.
newcon
(
host
,
config
)
self
.
test_stmt_insert_multi
(
connectstmt
)
return
# add case with filename
#
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/system-test/1-insert/test_stmt_set_tbname_tag.py
0 → 100644
浏览文件 @
2f7ff301
###################################################################
# 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
import
os
import
threading
as
thd
import
multiprocessing
as
mp
from
numpy.lib.function_base
import
insert
import
taos
from
taos
import
*
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
import
datetime
as
dt
from
datetime
import
datetime
from
ctypes
import
*
import
time
# constant define
WAITS
=
5
# wait seconds
class
TDTestCase
:
#
# --------------- main frame -------------------
def
caseDescription
(
self
):
'''
limit and offset keyword function test cases;
case1: limit offset base function test
case2: offset return valid
'''
return
def
getBuildPath
(
self
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
if
(
"community"
in
selfPath
):
projPath
=
selfPath
[:
selfPath
.
find
(
"community"
)]
else
:
projPath
=
selfPath
[:
selfPath
.
find
(
"tests"
)]
for
root
,
dirs
,
files
in
os
.
walk
(
projPath
):
if
(
"taosd"
in
files
):
rootRealPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
root
))
if
(
"packaging"
not
in
rootRealPath
):
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
break
return
buildPath
# init
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
# tdSql.prepare()
# self.create_tables();
self
.
ts
=
1500000000000
# stop
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
# --------------- case -------------------
def
newcon
(
self
,
host
,
cfg
):
user
=
"root"
password
=
"taosdata"
port
=
6030
con
=
taos
.
connect
(
host
=
host
,
user
=
user
,
password
=
password
,
config
=
cfg
,
port
=
port
)
print
(
con
)
return
con
def
test_stmt_set_tbname_tag
(
self
,
conn
):
dbname
=
"pytest_taos_stmt_set_tbname_tag"
try
:
conn
.
execute
(
"drop database if exists %s"
%
dbname
)
conn
.
execute
(
"create database if not exists %s PRECISION 'us' "
%
dbname
)
conn
.
select_db
(
dbname
)
conn
.
execute
(
"create table if not exists log(ts timestamp, bo bool, nil tinyint, ti tinyint, si smallint, ii int,
\
bi bigint, tu tinyint unsigned, su smallint unsigned, iu int unsigned, bu bigint unsigned,
\
ff float, dd double, bb binary(100), nn nchar(100), tt timestamp , vc varchar(100)) tags (t1 timestamp, t2 bool,
\
t3 tinyint, t4 tinyint, t5 smallint, t6 int, t7 bigint, t8 tinyint unsigned, t9 smallint unsigned,
\
t10 int unsigned, t11 bigint unsigned, t12 float, t13 double, t14 binary(100), t15 nchar(100), t16 timestamp)"
)
stmt
=
conn
.
statement
(
"insert into ? using log tags (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
\
values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
)
tags
=
new_bind_params
(
16
)
tags
[
0
].
timestamp
(
1626861392589123
,
PrecisionEnum
.
Microseconds
)
tags
[
1
].
bool
(
True
)
tags
[
2
].
null
()
tags
[
3
].
tinyint
(
2
)
tags
[
4
].
smallint
(
3
)
tags
[
5
].
int
(
4
)
tags
[
6
].
bigint
(
5
)
tags
[
7
].
tinyint_unsigned
(
6
)
tags
[
8
].
smallint_unsigned
(
7
)
tags
[
9
].
int_unsigned
(
8
)
tags
[
10
].
bigint_unsigned
(
9
)
tags
[
11
].
float
(
10.1
)
tags
[
12
].
double
(
10.11
)
tags
[
13
].
binary
(
"hello"
)
tags
[
14
].
nchar
(
"stmt"
)
tags
[
15
].
timestamp
(
1626861392589
,
PrecisionEnum
.
Milliseconds
)
stmt
.
set_tbname_tags
(
"tb1"
,
tags
)
params
=
new_multi_binds
(
16
)
params
[
0
].
timestamp
((
1626861392589111
,
1626861392590111
,
1626861392591111
))
params
[
1
].
bool
((
True
,
None
,
False
))
params
[
2
].
tinyint
([
-
128
,
-
128
,
None
])
# -128 is tinyint null
params
[
3
].
tinyint
([
0
,
127
,
None
])
params
[
4
].
smallint
([
3
,
None
,
2
])
params
[
5
].
int
([
3
,
4
,
None
])
params
[
6
].
bigint
([
3
,
4
,
None
])
params
[
7
].
tinyint_unsigned
([
3
,
4
,
None
])
params
[
8
].
smallint_unsigned
([
3
,
4
,
None
])
params
[
9
].
int_unsigned
([
3
,
4
,
None
])
params
[
10
].
bigint_unsigned
([
3
,
4
,
5
])
params
[
11
].
float
([
3
,
None
,
1
])
params
[
12
].
double
([
3
,
None
,
1.2
])
params
[
13
].
binary
([
"abc"
,
"dddafadfadfadfadfa"
,
None
])
params
[
14
].
nchar
([
"涛思数据"
,
None
,
"a long string with 中文字符"
])
params
[
15
].
timestamp
([
None
,
None
,
1626861392591
])
params
[
16
].
binary
([
"涛思数据16"
,
None
,
"a long string with 中文-字符"
])
stmt
.
bind_param_batch
(
params
)
stmt
.
execute
()
assert
stmt
.
affected_rows
==
3
#query
querystmt1
=
conn
.
statement
(
"select * from log where bu < ?"
)
queryparam1
=
new_bind_params
(
1
)
print
(
type
(
queryparam1
))
queryparam1
[
0
].
int
(
5
)
querystmt1
.
bind_param
(
queryparam1
)
querystmt1
.
execute
()
result1
=
querystmt1
.
use_result
()
rows1
=
result1
.
fetch_all
()
print
(
rows1
)
# assert str(rows1[0][0]) == "2021-07-21 17:56:32.589111"
# assert rows1[0][10] == 3
# assert rows1[1][10] == 4
# conn.execute("drop database if exists %s" % dbname)
conn
.
close
()
except
Exception
as
err
:
# conn.execute("drop database if exists %s" % dbname)
conn
.
close
()
raise
err
def
run
(
self
):
buildPath
=
self
.
getBuildPath
()
config
=
buildPath
+
"../sim/dnode1/cfg/"
host
=
"localhost"
connectstmt
=
self
.
newcon
(
host
,
config
)
self
.
test_stmt_set_tbname_tag
(
connectstmt
)
return
# add case with filename
#
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/system-test/fulltest.sh
浏览文件 @
2f7ff301
...
...
@@ -15,7 +15,7 @@ python3 ./test.py -f 0-others/user_control.py
python3 ./test.py
-f
0-others/fsync.py
python3 ./test.py
-f
1-insert/opentsdb_telnet_line_taosc_insert.py
python3 ./test.py
-f
1-insert/test_stmt_
insert_query.py
python3 ./test.py
-f
1-insert/test_stmt_
muti_insert_query.py
python3 ./test.py
-f
2-query/between.py
python3 ./test.py
-f
2-query/distinct.py
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录