提交 e84be94b 编写于 作者: G Ganlin Zhao

fixed python connector and test cases;

上级 ddb33879
......@@ -816,19 +816,22 @@ except AttributeError:
def taos_schemaless_insert(connection, lines, protocol, precision, msg_size=512):
def taos_schemaless_insert(connection, lines, protocol, precision):
# type: (c_void_p, list[str] | tuple(str)) -> None
num_of_lines = len(lines)
lines = (c_char_p(line.encode("utf-8")) for line in lines)
lines_type = ctypes.c_char_p * num_of_lines
p_lines = lines_type(*lines)
if precision is not None:
precision = c_char_p(precision.encode("utf-8"))
a_lines = c_int()
msg = create_string_buffer(msg_size)
errno = _libtaos.taos_schemaless_insert(connection, p_lines, num_of_lines, protocol, precision, byref(a_lines), msg, msg_size)
res = c_void_p(_libtaos.taos_schemaless_insert(connection, p_lines, num_of_lines, protocol, precision))
errno = taos_errno(res)
if errno != 0:
raise SchemalessError("schemaless insert error({}), affected_rows({})".format(msg.value.decode("utf-8"), a_lines.value), errno)
errstr = taos_errstr(res)
taos_free_result(res)
print("schemaless_insert error affected rows: {}".format(taos_affected_rows(res)))
raise SchemalessError(errstr, errno)
taos_free_result(res)
return errno
class CTaosInterface(object):
def __init__(self, config=None):
......
......@@ -15,6 +15,7 @@ import sys
from util.log import *
from util.cases import *
from util.sql import *
from util.types import TDSmlProtocolType, TDSmlTimestampType
class TDTestCase:
......@@ -46,7 +47,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe `.stb.0.`")
......@@ -67,7 +68,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_0")
......@@ -86,7 +87,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_1")
......@@ -105,7 +106,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_2")
......@@ -124,7 +125,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_3")
......@@ -143,7 +144,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_4")
......@@ -162,7 +163,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_5")
......@@ -184,7 +185,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
### timestamp 10 digits second ###
......@@ -201,7 +202,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
print("============= step3 : test tags ================")
......@@ -216,7 +217,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_8")
......@@ -232,7 +233,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_9")
......@@ -248,7 +249,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb0_10")
......@@ -274,7 +275,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select ts from stb1_0")
......@@ -297,7 +298,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select ts from stb1_1")
......@@ -320,7 +321,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select ts from stb1_2")
......@@ -343,7 +344,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select ts from stb1_3")
......@@ -367,7 +368,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
### metric value ###
......@@ -390,7 +391,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_0")
......@@ -415,7 +416,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_1")
......@@ -440,7 +441,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_2")
......@@ -465,7 +466,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_3")
......@@ -490,7 +491,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_4")
......@@ -515,7 +516,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_5")
......@@ -540,7 +541,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_6")
......@@ -565,7 +566,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_7")
......@@ -590,7 +591,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb2_8")
......@@ -649,7 +650,7 @@ class TDTestCase:
}
}
''']
code = self._conn.schemaless_insert(payload, 2, None)
code = self._conn.schemaless_insert(payload, TDSmlProtocolType.JSON.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("describe stb3_0")
......
......@@ -15,7 +15,7 @@ import sys
from util.log import *
from util.cases import *
from util.sql import *
from util.types import TDSmlProtocolType, TDSmlTimestampType
class TDTestCase:
def init(self, conn, logSql):
......@@ -39,7 +39,7 @@ class TDTestCase:
"`.stb0.3.` 1626006833639000000ns 4i8 host=\"host0\" interface=\"eth0\"",
]
code = self._conn.schemaless_insert(lines0, 1, None)
code = self._conn.schemaless_insert(lines0, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("show stables")
......@@ -69,7 +69,7 @@ class TDTestCase:
"stb1 0 7i8 host=\"host0\"",
]
code = self._conn.schemaless_insert(lines1, 1, None)
code = self._conn.schemaless_insert(lines1, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb1")
......@@ -83,7 +83,7 @@ class TDTestCase:
"stb2_0 1626006833651ms -127i8 host=\"host0\"",
"stb2_0 1626006833652ms 127i8 host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_0, 1, None)
code = self._conn.schemaless_insert(lines2_0, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_0")
......@@ -98,7 +98,7 @@ class TDTestCase:
"stb2_1 1626006833651ms -32767i16 host=\"host0\"",
"stb2_1 1626006833652ms 32767i16 host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_1, 1, None)
code = self._conn.schemaless_insert(lines2_1, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_1")
......@@ -114,7 +114,7 @@ class TDTestCase:
"stb2_2 1626006833652ms 2147483647i32 host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_2, 1, None)
code = self._conn.schemaless_insert(lines2_2, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_2")
......@@ -130,7 +130,7 @@ class TDTestCase:
"stb2_3 1626006833652ms 9223372036854775807i64 host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_3, 1, None)
code = self._conn.schemaless_insert(lines2_3, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_3")
......@@ -154,7 +154,7 @@ class TDTestCase:
"stb2_4 1626006833710ms -3.4E38f32 host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_4, 1, None)
code = self._conn.schemaless_insert(lines2_4, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_4")
......@@ -179,7 +179,7 @@ class TDTestCase:
"stb2_5 1626006833710ms 3 host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_5, 1, None)
code = self._conn.schemaless_insert(lines2_5, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_5")
......@@ -203,7 +203,7 @@ class TDTestCase:
"stb2_6 1626006833700ms FALSE host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_6, 1, None)
code = self._conn.schemaless_insert(lines2_6, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_6")
......@@ -220,7 +220,7 @@ class TDTestCase:
"stb2_7 1626006833630ms \"binary_val.()[]{}<>\" host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_7, 1, None)
code = self._conn.schemaless_insert(lines2_7, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_7")
......@@ -236,7 +236,7 @@ class TDTestCase:
"stb2_8 1626006833620ms L\"nchar_val数值二\" host=\"host0\""
]
code = self._conn.schemaless_insert(lines2_8, 1, None)
code = self._conn.schemaless_insert(lines2_8, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb2_8")
......@@ -254,7 +254,7 @@ class TDTestCase:
"stb3_0 1626006833610ms 2 t1=-127i8 t2=-32767i16 t3=-2147483647i32 t4=-9223372036854775807i64 t5=-3.4E38f32 t6=-1.7E308f64 t7=false t8=\"binary_val_2\" t9=L\"标签值2\""
]
code = self._conn.schemaless_insert(lines3_0, 1, None)
code = self._conn.schemaless_insert(lines3_0, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb3_0")
......@@ -298,7 +298,7 @@ class TDTestCase:
"stb3_1 1626006833610ms 3 ID=child_table3 host=host3"
]
code = self._conn.schemaless_insert(lines3_1, 1, None)
code = self._conn.schemaless_insert(lines3_1, TDSmlProtocolType.TELNET.value, TDSmlTimestampType.NOT_CONFIGURED.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from stb3_1")
......
......@@ -15,13 +15,14 @@ import sys
from util.log import *
from util.cases import *
from util.sql import *
from util.types import TDSmlProtocolType, TDSmlTimestampType
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self._conn = conn
self._conn = conn
def run(self):
print("running {}".format(__file__))
......@@ -42,17 +43,17 @@ class TDTestCase:
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000"
]
code = self._conn.schemaless_insert(lines, 0, "ns")
code = self._conn.schemaless_insert(lines, TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
print("schemaless_insert result {}".format(code))
lines2 = [ "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
"stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000"
]
code = self._conn.schemaless_insert([ lines2[0] ], 0, "ns")
code = self._conn.schemaless_insert([ lines2[0] ], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
print("schemaless_insert result {}".format(code))
self._conn.schemaless_insert([ lines2[1] ], 0, "ns")
code = self._conn.schemaless_insert([ lines2[1] ], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
print("schemaless_insert result {}".format(code))
tdSql.query("select * from st")
......@@ -76,7 +77,7 @@ class TDTestCase:
self._conn.schemaless_insert([
"sth,t1=4i64,t2=5f64,t4=5f64,ID=childtable c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641",
"sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654"
], 0, "ms")
], TDSmlProtocolType.LINE.value, TDSmlTimestampType.MILLI_SECOND.value)
tdSql.execute('reset query cache')
tdSql.query('select tbname, * from sth')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册