Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7615341d
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看板
提交
7615341d
编写于
7月 16, 2022
作者:
J
jiacy-jcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
fb6d4a56
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
131 addition
and
87 deletion
+131
-87
tests/system-test/1-insert/update_data.py
tests/system-test/1-insert/update_data.py
+131
-87
未找到文件。
tests/system-test/1-insert/update_data.py
浏览文件 @
7615341d
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from
optparse
import
Values
import
random
import
random
import
string
import
string
from
util
import
constant
from
util
import
constant
...
@@ -18,16 +19,18 @@ from util.log import *
...
@@ -18,16 +19,18 @@ from util.log import *
from
util.cases
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.sql
import
*
from
util.common
import
*
from
util.common
import
*
from
util.sqlset
import
TDSetSql
class
TDTestCase
:
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
tdSql
.
init
(
conn
.
cursor
())
self
.
setsql
=
TDSetSql
()
self
.
dbname
=
'db_test'
self
.
dbname
=
'db_test'
self
.
ntbname
=
'ntb'
self
.
ntbname
=
'ntb'
self
.
stbname
=
'stb'
self
.
stbname
=
'stb'
self
.
ctbname
=
'ctb'
self
.
ts
=
1537146000000
self
.
ts
=
1537146000000
self
.
str_length
=
20
self
.
str_length
=
20
self
.
column_dict
=
{
self
.
column_dict
=
{
'col1'
:
'tinyint'
,
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col2'
:
'smallint'
,
...
@@ -44,19 +47,19 @@ class TDTestCase:
...
@@ -44,19 +47,19 @@ class TDTestCase:
'col13'
:
f
'nchar(
{
self
.
str_length
}
)'
,
'col13'
:
f
'nchar(
{
self
.
str_length
}
)'
,
'col_ts'
:
'timestamp'
'col_ts'
:
'timestamp'
}
}
self
.
tinyint
=
random
.
randint
(
constant
.
TINYINT_MIN
,
constant
.
TINYINT_MAX
)
self
.
tinyint
=
None
self
.
smallint
=
random
.
randint
(
constant
.
SMALLINT_MIN
,
constant
.
SMALLINT_MAX
)
self
.
smallint
=
None
self
.
int
=
random
.
randint
(
constant
.
INT_MIN
,
constant
.
INT_MAX
)
self
.
int
=
None
self
.
bigint
=
random
.
randint
(
constant
.
BIGINT_MIN
,
constant
.
BIGINT_MAX
)
self
.
bigint
=
None
self
.
untinyint
=
random
.
randint
(
constant
.
TINYINT_UN_MIN
,
constant
.
TINYINT_UN_MAX
)
self
.
untinyint
=
None
self
.
unsmallint
=
random
.
randint
(
constant
.
SMALLINT_UN_MIN
,
constant
.
SMALLINT_UN_MAX
)
self
.
unsmallint
=
None
self
.
unint
=
random
.
randint
(
constant
.
INT_UN_MIN
,
constant
.
INT_MAX
)
self
.
unint
=
None
self
.
unbigint
=
random
.
randint
(
constant
.
BIGINT_UN_MIN
,
constant
.
BIGINT_UN_MAX
)
self
.
unbigint
=
None
self
.
bool
=
random
.
randint
(
0
,
100
)
%
2
self
.
bool
=
None
self
.
float
=
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
)
self
.
float
=
None
self
.
double
=
random
.
uniform
(
constant
.
DOUBLE_MIN
*
(
1E-300
),
constant
.
DOUBLE_MAX
*
(
1E-300
))
self
.
double
=
None
self
.
binary
=
tdCom
.
getLongName
(
self
.
str_length
)
self
.
binary
=
None
self
.
tnchar
=
tdCom
.
getLongName
(
self
.
str_length
)
self
.
tnchar
=
None
def
insert_base_data
(
self
,
col_type
,
tbname
,
value
=
None
):
def
insert_base_data
(
self
,
col_type
,
tbname
,
value
=
None
):
if
value
==
None
:
if
value
==
None
:
if
col_type
.
lower
()
==
'tinyint'
:
if
col_type
.
lower
()
==
'tinyint'
:
...
@@ -94,7 +97,6 @@ class TDTestCase:
...
@@ -94,7 +97,6 @@ class TDTestCase:
tdLog
.
exit
(
f
'
{
col_name
}
data check failure'
)
tdLog
.
exit
(
f
'
{
col_name
}
data check failure'
)
else
:
else
:
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
value
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
value
)
pass
def
update_and_check_data
(
self
,
tbname
,
col_name
,
col_type
,
value
,
dbname
):
def
update_and_check_data
(
self
,
tbname
,
col_name
,
col_type
,
value
,
dbname
):
if
'binary'
in
col_type
.
lower
()
or
'nchar'
in
col_type
.
lower
():
if
'binary'
in
col_type
.
lower
()
or
'nchar'
in
col_type
.
lower
():
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,"
{
value
}
")'
)
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,"
{
value
}
")'
)
...
@@ -102,8 +104,57 @@ class TDTestCase:
...
@@ -102,8 +104,57 @@ class TDTestCase:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
value
}
)'
)
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
value
}
)'
)
self
.
data_check
(
tbname
,
col_name
,
col_type
,
value
)
self
.
data_check
(
tbname
,
col_name
,
col_type
,
value
)
tdSql
.
execute
(
f
'flush database
{
dbname
}
'
)
tdSql
.
execute
(
f
'flush database
{
dbname
}
'
)
tdSql
.
execute
(
'reset query cache'
)
self
.
data_check
(
tbname
,
col_name
,
col_type
,
value
)
self
.
data_check
(
tbname
,
col_name
,
col_type
,
value
)
def
update_check_ntb
(
self
):
def
error_check
(
self
,
tbname
,
column_dict
,
tb_type
=
None
,
stbname
=
None
):
str_length
=
self
.
str_length
+
1
for
col_name
,
col_type
in
column_dict
.
items
():
if
tb_type
==
'ntb'
:
tdSql
.
execute
(
f
'create table
{
tbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
)'
)
elif
tb_type
==
'ctb'
:
tdSql
.
execute
(
f
'create table
{
stbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
) tags(t0 int)'
)
tdSql
.
execute
(
f
'create table
{
tbname
}
using
{
stbname
}
tags(1)'
)
self
.
insert_base_data
(
col_name
,
tbname
)
if
col_type
.
lower
()
==
'double'
:
for
error_value
in
[
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
,
1.1
*
constant
.
DOUBLE_MIN
,
1.1
*
constant
.
DOUBLE_MAX
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'float'
:
for
error_value
in
[
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
,
1.1
*
constant
.
FLOAT_MIN
,
1.1
*
constant
.
FLOAT_MAX
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
'binary'
in
col_type
.
lower
()
or
'nchar'
in
col_type
.
lower
():
for
error_value
in
[
tdCom
.
getLongName
(
str_length
)]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,"
{
error_value
}
")'
)
elif
col_type
.
lower
()
==
'bool'
:
for
error_value
in
[
tdCom
.
getLongName
(
self
.
str_length
)]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'tinyint'
:
for
error_value
in
[
constant
.
TINYINT_MIN
-
1
,
constant
.
TINYINT_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'smallint'
:
for
error_value
in
[
constant
.
SMALLINT_MIN
-
1
,
constant
.
SMALLINT_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'int'
:
for
error_value
in
[
constant
.
INT_MIN
-
1
,
constant
.
INT_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'bigint'
:
for
error_value
in
[
constant
.
BIGINT_MIN
-
1
,
constant
.
BIGINT_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'tinyint unsigned'
:
for
error_value
in
[
constant
.
TINYINT_UN_MIN
-
1
,
constant
.
TINYINT_UN_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'smallint unsigned'
:
for
error_value
in
[
constant
.
SMALLINT_UN_MIN
-
1
,
constant
.
SMALLINT_UN_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'int unsigned'
:
for
error_value
in
[
constant
.
INT_UN_MIN
-
1
,
constant
.
INT_UN_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'bigint unsigned'
:
for
error_value
in
[
constant
.
BIGINT_UN_MIN
-
1
,
constant
.
BIGINT_UN_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
tdSql
.
execute
(
f
'drop table
{
tbname
}
'
)
if
tb_type
==
'ctb'
:
tdSql
.
execute
(
f
'drop table
{
stbname
}
'
)
def
update_data_check
(
self
,
tbname
,
column_dict
,
dbname
,
tb_type
=
None
,
stbname
=
None
):
up_tinyint
=
random
.
randint
(
constant
.
TINYINT_MIN
,
constant
.
TINYINT_MAX
)
up_tinyint
=
random
.
randint
(
constant
.
TINYINT_MIN
,
constant
.
TINYINT_MAX
)
up_smallint
=
random
.
randint
(
constant
.
SMALLINT_MIN
,
constant
.
SMALLINT_MAX
)
up_smallint
=
random
.
randint
(
constant
.
SMALLINT_MIN
,
constant
.
SMALLINT_MAX
)
up_int
=
random
.
randint
(
constant
.
INT_MIN
,
constant
.
INT_MAX
)
up_int
=
random
.
randint
(
constant
.
INT_MIN
,
constant
.
INT_MAX
)
...
@@ -119,102 +170,95 @@ class TDTestCase:
...
@@ -119,102 +170,95 @@ class TDTestCase:
nchar_length
=
random
.
randint
(
0
,
self
.
str_length
)
nchar_length
=
random
.
randint
(
0
,
self
.
str_length
)
up_binary
=
tdCom
.
getLongName
(
binary_length
)
up_binary
=
tdCom
.
getLongName
(
binary_length
)
up_nchar
=
tdCom
.
getLongName
(
nchar_length
)
up_nchar
=
tdCom
.
getLongName
(
nchar_length
)
tdSql
.
execute
(
f
'drop database if exists
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
for
col_name
,
col_type
in
column_dict
.
items
():
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
if
tb_type
==
'ntb'
:
tdSql
.
execute
(
f
'create table
{
tbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
)'
)
for
col_name
,
col_type
in
self
.
column_dict
.
items
():
elif
tb_type
==
'ctb'
:
tdSql
.
execute
(
f
'create table
{
self
.
ntbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
)'
)
tdSql
.
execute
(
f
'create table
{
stbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
) tags(t0 int)'
)
self
.
insert_base_data
(
col_name
,
self
.
ntbname
)
tdSql
.
execute
(
f
'create table
{
tbname
}
using
{
stbname
}
tags(1)'
)
self
.
insert_base_data
(
col_name
,
tbname
)
if
col_type
.
lower
()
==
'tinyint'
:
if
col_type
.
lower
()
==
'tinyint'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_tinyint
,
self
.
dbname
)
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_tinyint
,
dbname
)
elif
col_type
.
lower
()
==
'smallint'
:
elif
col_type
.
lower
()
==
'smallint'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_smallint
,
self
.
dbname
)
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_smallint
,
dbname
)
elif
col_type
.
lower
()
==
'int'
:
elif
col_type
.
lower
()
==
'int'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_int
,
self
.
dbname
)
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_int
,
dbname
)
elif
col_type
.
lower
()
==
'bigint'
:
elif
col_type
.
lower
()
==
'bigint'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_bigint
,
self
.
dbname
)
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_bigint
,
dbname
)
elif
col_type
.
lower
()
==
'tinyint unsigned'
:
elif
col_type
.
lower
()
==
'tinyint unsigned'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_untinyint
,
self
.
dbname
)
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_untinyint
,
dbname
)
elif
col_type
.
lower
()
==
'smallint unsigned'
:
elif
col_type
.
lower
()
==
'smallint unsigned'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_unsmallint
,
self
.
dbname
)
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_unsmallint
,
dbname
)
elif
col_type
.
lower
()
==
'int unsigned'
:
elif
col_type
.
lower
()
==
'int unsigned'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_unint
,
self
.
dbname
)
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_unint
,
dbname
)
elif
col_type
.
lower
()
==
'bigint unsigned'
:
elif
col_type
.
lower
()
==
'bigint unsigned'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_unbigint
,
self
.
dbname
)
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_unbigint
,
dbname
)
elif
col_type
.
lower
()
==
'bool'
:
elif
col_type
.
lower
()
==
'bool'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_bool
,
self
.
dbname
)
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_bool
,
dbname
)
elif
col_type
.
lower
()
==
'float'
:
elif
col_type
.
lower
()
==
'float'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_float
,
self
.
dbname
)
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_float
,
dbname
)
elif
col_type
.
lower
()
==
'double'
:
elif
col_type
.
lower
()
==
'double'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_double
,
self
.
dbname
)
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_double
,
dbname
)
elif
'binary'
in
col_type
.
lower
():
elif
'binary'
in
col_type
.
lower
():
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_binary
,
self
.
dbname
)
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_binary
,
dbname
)
elif
'nchar'
in
col_type
.
lower
():
elif
'nchar'
in
col_type
.
lower
():
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_nchar
,
self
.
dbname
)
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_nchar
,
dbname
)
tdSql
.
execute
(
f
'drop table
{
self
.
ntbname
}
'
)
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,null)'
)
for
col_name
,
col_type
in
self
.
column_dict
.
items
():
tdSql
.
query
(
f
'select
{
col_name
}
from
{
tbname
}
'
)
tdSql
.
execute
(
f
'create table
{
self
.
ntbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
)'
)
self
.
insert_base_data
(
col_name
,
self
.
ntbname
)
tdSql
.
execute
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,null)'
)
tdSql
.
query
(
f
'select
{
col_name
}
from
{
self
.
ntbname
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
None
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
None
)
tdSql
.
execute
(
f
'flush database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'flush database
{
self
.
dbname
}
'
)
tdSql
.
query
(
f
'select
{
col_name
}
from
{
self
.
ntbname
}
'
)
tdSql
.
execute
(
'reset query cache'
)
tdSql
.
query
(
f
'select
{
col_name
}
from
{
tbname
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
None
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
None
)
tdSql
.
execute
(
f
'drop table
{
self
.
n
tbname
}
'
)
tdSql
.
execute
(
f
'drop table
{
tbname
}
'
)
if
tb_type
==
'ctb'
:
tdSql
.
execute
(
f
'drop table
{
stbname
}
'
)
def
update_check
_error_ntb
(
self
):
def
update_check
(
self
):
tdSql
.
execute
(
f
'drop database if exists
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'drop database if exists
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
s
tr_length
=
self
.
str_length
+
1
s
elf
.
update_data_check
(
self
.
ntbname
,
self
.
column_dict
,
self
.
dbname
,
'ntb'
)
for
col_name
,
col_type
in
self
.
column_dict
.
items
():
for
col_name
,
col_type
in
self
.
column_dict
.
items
():
tdSql
.
execute
(
f
'create table
{
self
.
ntbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
)'
)
tdSql
.
execute
(
f
'create table
{
self
.
ntbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
)'
)
self
.
insert_base_data
(
col_name
,
self
.
ntbname
)
self
.
insert_base_data
(
col_name
,
self
.
ntbname
)
if
col_type
.
lower
()
==
'double'
:
if
'binary'
in
col_type
.
lower
():
for
error_value
in
[
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
,
1.1
*
constant
.
DOUBLE_MIN
,
1.1
*
constant
.
DOUBLE_MAX
]:
up_binary
=
tdCom
.
getLongName
(
self
.
str_length
+
1
)
tdSql
.
error
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
tdSql
.
execute
(
f
'alter table
{
self
.
ntbname
}
modify column
{
col_name
}
binary(
{
self
.
str_length
+
1
}
)'
)
elif
col_type
.
lower
()
==
'float'
:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_binary
,
self
.
dbname
)
for
error_value
in
[
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
,
1.1
*
constant
.
FLOAT_MIN
,
1.1
*
constant
.
FLOAT_MAX
]:
elif
'nchar'
in
col_type
.
lower
():
tdSql
.
error
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
up_nchar
=
tdCom
.
getLongName
(
self
.
str_length
+
1
)
elif
'binary'
in
col_type
.
lower
()
or
'nchar'
in
col_type
.
lower
():
tdSql
.
execute
(
f
'alter table
{
self
.
ntbname
}
modify column
{
col_name
}
nchar(
{
self
.
str_length
+
1
}
)'
)
for
error_value
in
[
tdCom
.
getLongName
(
str_length
)]:
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_nchar
,
self
.
dbname
)
tdSql
.
error
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,"
{
error_value
}
")'
)
elif
col_type
.
lower
()
==
'bool'
:
for
error_value
in
[
tdCom
.
getLongName
(
self
.
str_length
)]:
tdSql
.
error
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'tinyint'
:
for
error_value
in
[
constant
.
TINYINT_MIN
-
1
,
constant
.
TINYINT_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'smallint'
:
for
error_value
in
[
constant
.
SMALLINT_MIN
-
1
,
constant
.
SMALLINT_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'int'
:
for
error_value
in
[
constant
.
INT_MIN
-
1
,
constant
.
INT_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'bigint'
:
for
error_value
in
[
constant
.
BIGINT_MIN
-
1
,
constant
.
BIGINT_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'tinyint unsigned'
:
for
error_value
in
[
constant
.
TINYINT_UN_MIN
-
1
,
constant
.
TINYINT_UN_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'smallint unsigned'
:
for
error_value
in
[
constant
.
SMALLINT_UN_MIN
-
1
,
constant
.
SMALLINT_UN_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'int unsigned'
:
for
error_value
in
[
constant
.
INT_UN_MIN
-
1
,
constant
.
INT_UN_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'bigint unsigned'
:
for
error_value
in
[
constant
.
BIGINT_UN_MIN
-
1
,
constant
.
BIGINT_UN_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
tdSql
.
execute
(
f
'drop table
{
self
.
ntbname
}
'
)
tdSql
.
execute
(
f
'drop table
{
self
.
ntbname
}
'
)
self
.
update_data_check
(
self
.
ctbname
,
self
.
column_dict
,
self
.
dbname
,
'ctb'
,
self
.
stbname
)
for
col_name
,
col_type
in
self
.
column_dict
.
items
():
tdSql
.
execute
(
f
'create table
{
self
.
stbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
) tags(t0 int)'
)
tdSql
.
execute
(
f
'create table
{
self
.
ctbname
}
using
{
self
.
stbname
}
tags(1)'
)
self
.
insert_base_data
(
col_name
,
self
.
ctbname
)
if
'binary'
in
col_type
.
lower
():
up_binary
=
tdCom
.
getLongName
(
self
.
str_length
+
1
)
tdSql
.
execute
(
f
'alter table
{
self
.
stbname
}
modify column
{
col_name
}
binary(
{
self
.
str_length
+
1
}
)'
)
self
.
update_and_check_data
(
self
.
ctbname
,
col_name
,
col_type
,
up_binary
,
self
.
dbname
)
elif
'nchar'
in
col_type
.
lower
():
up_nchar
=
tdCom
.
getLongName
(
self
.
str_length
+
1
)
tdSql
.
execute
(
f
'alter table
{
self
.
stbname
}
modify column
{
col_name
}
nchar(
{
self
.
str_length
+
1
}
)'
)
self
.
update_and_check_data
(
self
.
ctbname
,
col_name
,
col_type
,
up_nchar
,
self
.
dbname
)
tdSql
.
execute
(
f
'drop table
{
self
.
stbname
}
'
)
def
run
(
self
):
self
.
update_check_ntb
()
def
update_check_error
(
self
):
self
.
update_check_error_ntb
()
tdSql
.
execute
(
f
'drop database if exists
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
self
.
error_check
(
self
.
ntbname
,
self
.
column_dict
,
'ntb'
)
self
.
error_check
(
self
.
ctbname
,
self
.
column_dict
,
'ctb'
,
self
.
stbname
)
def
run
(
self
):
self
.
update_check
()
self
.
update_check_error
()
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录