TDengine/tests/pytest/insert/line_insert.py

94 lines
3.9 KiB
Python
Raw Normal View History

###################################################################
# Copyright (c) 2021 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)
self._conn = conn
def run(self):
print("running {}".format(__file__))
tdSql.execute("drop database if exists test")
tdSql.execute("create database if not exists test precision 'us'")
tdSql.execute('use test')
tdSql.execute('create stable ste(ts timestamp, f int) tags(t1 bigint)')
2021-07-15 00:19:48 +00:00
lines = [ "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns",
"st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000ns",
"ste,t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\"iam\" 1626056811823316532ns",
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns",
"st,t1=4i64,t2=5f64,t3=\"t4\" c1=3i64,c3=L\"passitagain\",c2=true,c4=5f64 1626006833642000000ns",
"ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532ns",
"ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532ns",
"st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns",
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000ns"
]
[TD-3048]<feature>: support lines/stream/query_a/stop_query/ and so on. (#7079) * [TD-3048]<feature>: support lines/stream/query_a/stop_query/ and so on. commit 0edc106a76a95b28e65019c2ee4e4ed84530ad35 Author: Huo Linhe <linhehuo@gmail.com> Date: Thu Jul 29 21:13:13 2021 +0800 doc: improve document for python connector commit 84915de0831b49c8378a16242dd0dbba8aaf386f Author: Huo Linhe <linhehuo@gmail.com> Date: Thu Jul 29 20:35:45 2021 +0800 chore: add time elapsed commit 1e8822e01bda96388a359363776792e261260b88 Author: Huo Linhe <linhehuo@gmail.com> Date: Thu Jul 29 20:26:01 2021 +0800 feat: support multi bind commit 82d823f6194471fd3324b50f7dfba0ee9f10a7dd Author: Huo Linhe <linhehuo@gmail.com> Date: Thu Jul 29 16:42:05 2021 +0800 feat: python support for async query and subscribe with callback commit 8b9d36de2945906821225189cb47958e153d81e2 Author: Huo Linhe <linhehuo@gmail.com> Date: Wed Jul 28 18:09:09 2021 +0800 feat: finish stream and stmt interface commit bc871aa43e9fc28dd1b3f8784a8ac6ee988564b5 Author: Huo Linhe <linhehuo@gmail.com> Date: Mon Jul 26 20:21:27 2021 +0800 feat: basic full-fetured implementations commit e5f7a5213e9016c377a57485e8d5c12139ce0957 Author: Huo Linhe <linhehuo@gmail.com> Date: Fri Jul 23 10:33:14 2021 +0800 tmp: refactor * chore: fix insert/line_insert.py error * [TD-3048]<fix>: fix tests error * [TD-3049]<feature>: support stop_query in python connector cursor * [TD-3048]<doc>: improve python connector document * [TD-3048]<doc>: improve python connection README * [TD-3048]<hotfix>: fix python2 install and runtime error * chore: replace insertLines with insert_lines * chore: fix misspellings * chore: fix crash gen error in threading * feat: support __del__ method for simplify * test: fix subscription test result check * chore: compatible with 2.0.20 * chore: fix python connector subscription test case * [TD-3048]<fix>: fix schemaless insert test * [TD-3048]<fix>: fix memory leak in crash_gen test case * [TD-3048]<fix>: minor fix for crash gen memory leak * [TD-3048]<fix>: set minimal required python3 as 3.4 * chore: update version in setup.py * [TD-3048]<fix>: fix runtime errors in python3.4 * [TD-3048]<fix>: add typing as a dependency
2021-08-07 00:00:37 +00:00
code = self._conn.insert_lines(lines)
print("insert_lines result {}".format(code))
2021-07-15 00:19:48 +00:00
lines2 = [ "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000ns",
"stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000ns"
]
[TD-3048]<feature>: support lines/stream/query_a/stop_query/ and so on. (#7079) * [TD-3048]<feature>: support lines/stream/query_a/stop_query/ and so on. commit 0edc106a76a95b28e65019c2ee4e4ed84530ad35 Author: Huo Linhe <linhehuo@gmail.com> Date: Thu Jul 29 21:13:13 2021 +0800 doc: improve document for python connector commit 84915de0831b49c8378a16242dd0dbba8aaf386f Author: Huo Linhe <linhehuo@gmail.com> Date: Thu Jul 29 20:35:45 2021 +0800 chore: add time elapsed commit 1e8822e01bda96388a359363776792e261260b88 Author: Huo Linhe <linhehuo@gmail.com> Date: Thu Jul 29 20:26:01 2021 +0800 feat: support multi bind commit 82d823f6194471fd3324b50f7dfba0ee9f10a7dd Author: Huo Linhe <linhehuo@gmail.com> Date: Thu Jul 29 16:42:05 2021 +0800 feat: python support for async query and subscribe with callback commit 8b9d36de2945906821225189cb47958e153d81e2 Author: Huo Linhe <linhehuo@gmail.com> Date: Wed Jul 28 18:09:09 2021 +0800 feat: finish stream and stmt interface commit bc871aa43e9fc28dd1b3f8784a8ac6ee988564b5 Author: Huo Linhe <linhehuo@gmail.com> Date: Mon Jul 26 20:21:27 2021 +0800 feat: basic full-fetured implementations commit e5f7a5213e9016c377a57485e8d5c12139ce0957 Author: Huo Linhe <linhehuo@gmail.com> Date: Fri Jul 23 10:33:14 2021 +0800 tmp: refactor * chore: fix insert/line_insert.py error * [TD-3048]<fix>: fix tests error * [TD-3049]<feature>: support stop_query in python connector cursor * [TD-3048]<doc>: improve python connector document * [TD-3048]<doc>: improve python connection README * [TD-3048]<hotfix>: fix python2 install and runtime error * chore: replace insertLines with insert_lines * chore: fix misspellings * chore: fix crash gen error in threading * feat: support __del__ method for simplify * test: fix subscription test result check * chore: compatible with 2.0.20 * chore: fix python connector subscription test case * [TD-3048]<fix>: fix schemaless insert test * [TD-3048]<fix>: fix memory leak in crash_gen test case * [TD-3048]<fix>: minor fix for crash gen memory leak * [TD-3048]<fix>: set minimal required python3 as 3.4 * chore: update version in setup.py * [TD-3048]<fix>: fix runtime errors in python3.4 * [TD-3048]<fix>: add typing as a dependency
2021-08-07 00:00:37 +00:00
code = self._conn.insert_lines([ lines2[0] ])
print("insert_lines result {}".format(code))
[TD-3048]<feature>: support lines/stream/query_a/stop_query/ and so on. (#7079) * [TD-3048]<feature>: support lines/stream/query_a/stop_query/ and so on. commit 0edc106a76a95b28e65019c2ee4e4ed84530ad35 Author: Huo Linhe <linhehuo@gmail.com> Date: Thu Jul 29 21:13:13 2021 +0800 doc: improve document for python connector commit 84915de0831b49c8378a16242dd0dbba8aaf386f Author: Huo Linhe <linhehuo@gmail.com> Date: Thu Jul 29 20:35:45 2021 +0800 chore: add time elapsed commit 1e8822e01bda96388a359363776792e261260b88 Author: Huo Linhe <linhehuo@gmail.com> Date: Thu Jul 29 20:26:01 2021 +0800 feat: support multi bind commit 82d823f6194471fd3324b50f7dfba0ee9f10a7dd Author: Huo Linhe <linhehuo@gmail.com> Date: Thu Jul 29 16:42:05 2021 +0800 feat: python support for async query and subscribe with callback commit 8b9d36de2945906821225189cb47958e153d81e2 Author: Huo Linhe <linhehuo@gmail.com> Date: Wed Jul 28 18:09:09 2021 +0800 feat: finish stream and stmt interface commit bc871aa43e9fc28dd1b3f8784a8ac6ee988564b5 Author: Huo Linhe <linhehuo@gmail.com> Date: Mon Jul 26 20:21:27 2021 +0800 feat: basic full-fetured implementations commit e5f7a5213e9016c377a57485e8d5c12139ce0957 Author: Huo Linhe <linhehuo@gmail.com> Date: Fri Jul 23 10:33:14 2021 +0800 tmp: refactor * chore: fix insert/line_insert.py error * [TD-3048]<fix>: fix tests error * [TD-3049]<feature>: support stop_query in python connector cursor * [TD-3048]<doc>: improve python connector document * [TD-3048]<doc>: improve python connection README * [TD-3048]<hotfix>: fix python2 install and runtime error * chore: replace insertLines with insert_lines * chore: fix misspellings * chore: fix crash gen error in threading * feat: support __del__ method for simplify * test: fix subscription test result check * chore: compatible with 2.0.20 * chore: fix python connector subscription test case * [TD-3048]<fix>: fix schemaless insert test * [TD-3048]<fix>: fix memory leak in crash_gen test case * [TD-3048]<fix>: minor fix for crash gen memory leak * [TD-3048]<fix>: set minimal required python3 as 3.4 * chore: update version in setup.py * [TD-3048]<fix>: fix runtime errors in python3.4 * [TD-3048]<fix>: add typing as a dependency
2021-08-07 00:00:37 +00:00
self._conn.insert_lines([ lines2[1] ])
print("insert_lines result {}".format(code))
tdSql.query("select * from st")
tdSql.checkRows(4)
tdSql.query("select * from ste")
tdSql.checkRows(3)
tdSql.query("select * from stf")
tdSql.checkRows(2)
tdSql.query("select * from stg")
tdSql.checkRows(2)
tdSql.query("show tables")
tdSql.checkRows(8)
tdSql.query("describe stf")
2021-07-15 00:19:48 +00:00
tdSql.checkData(2, 2, 14)
[TD-3048]<feature>: support lines/stream/query_a/stop_query/ and so on. (#7079) * [TD-3048]<feature>: support lines/stream/query_a/stop_query/ and so on. commit 0edc106a76a95b28e65019c2ee4e4ed84530ad35 Author: Huo Linhe <linhehuo@gmail.com> Date: Thu Jul 29 21:13:13 2021 +0800 doc: improve document for python connector commit 84915de0831b49c8378a16242dd0dbba8aaf386f Author: Huo Linhe <linhehuo@gmail.com> Date: Thu Jul 29 20:35:45 2021 +0800 chore: add time elapsed commit 1e8822e01bda96388a359363776792e261260b88 Author: Huo Linhe <linhehuo@gmail.com> Date: Thu Jul 29 20:26:01 2021 +0800 feat: support multi bind commit 82d823f6194471fd3324b50f7dfba0ee9f10a7dd Author: Huo Linhe <linhehuo@gmail.com> Date: Thu Jul 29 16:42:05 2021 +0800 feat: python support for async query and subscribe with callback commit 8b9d36de2945906821225189cb47958e153d81e2 Author: Huo Linhe <linhehuo@gmail.com> Date: Wed Jul 28 18:09:09 2021 +0800 feat: finish stream and stmt interface commit bc871aa43e9fc28dd1b3f8784a8ac6ee988564b5 Author: Huo Linhe <linhehuo@gmail.com> Date: Mon Jul 26 20:21:27 2021 +0800 feat: basic full-fetured implementations commit e5f7a5213e9016c377a57485e8d5c12139ce0957 Author: Huo Linhe <linhehuo@gmail.com> Date: Fri Jul 23 10:33:14 2021 +0800 tmp: refactor * chore: fix insert/line_insert.py error * [TD-3048]<fix>: fix tests error * [TD-3049]<feature>: support stop_query in python connector cursor * [TD-3048]<doc>: improve python connector document * [TD-3048]<doc>: improve python connection README * [TD-3048]<hotfix>: fix python2 install and runtime error * chore: replace insertLines with insert_lines * chore: fix misspellings * chore: fix crash gen error in threading * feat: support __del__ method for simplify * test: fix subscription test result check * chore: compatible with 2.0.20 * chore: fix python connector subscription test case * [TD-3048]<fix>: fix schemaless insert test * [TD-3048]<fix>: fix memory leak in crash_gen test case * [TD-3048]<fix>: minor fix for crash gen memory leak * [TD-3048]<fix>: set minimal required python3 as 3.4 * chore: update version in setup.py * [TD-3048]<fix>: fix runtime errors in python3.4 * [TD-3048]<fix>: add typing as a dependency
2021-08-07 00:00:37 +00:00
self._conn.insert_lines([
"sth,t1=4i64,t2=5f64,t4=5f64,ID=\"childtable\" c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641ms",
"sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654ms"
])
tdSql.execute('reset query cache')
tdSql.query('select tbname, * from sth')
tdSql.checkRows(2)
tdSql.query('select tbname, * from childtable')
tdSql.checkRows(1)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())