test:modify the keep parameter of db in python.sh cases

This commit is contained in:
chenhaoran 2023-12-07 10:04:47 +08:00
parent 48c5cc1165
commit 68f627ca03
32 changed files with 37 additions and 37 deletions

View File

@ -20,7 +20,7 @@ def get_ts(ts: str):
def create_stable(): def create_stable():
conn = taos.connect() conn = taos.connect()
try: try:
conn.execute("CREATE DATABASE power") conn.execute("CREATE DATABASE power keep 36500")
conn.execute("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) " conn.execute("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) "
"TAGS (location BINARY(64), groupId INT)") "TAGS (location BINARY(64), groupId INT)")
finally: finally:

View File

@ -4,7 +4,7 @@ import taos
taos_conn = taos.connect() taos_conn = taos.connect()
taos_conn.execute('drop database if exists power') taos_conn.execute('drop database if exists power')
taos_conn.execute('create database if not exists power wal_retention_period 3600') taos_conn.execute('create database if not exists power wal_retention_period 3600 keep 36500 ')
taos_conn.execute("use power") taos_conn.execute("use power")
taos_conn.execute( taos_conn.execute(
"CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)") "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)")

View File

@ -11,7 +11,7 @@ conn = connect(url="http://localhost:6041",
# create STable # create STable
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute("DROP DATABASE IF EXISTS power") cursor.execute("DROP DATABASE IF EXISTS power")
cursor.execute("CREATE DATABASE power") cursor.execute("CREATE DATABASE power keep 36500 ")
cursor.execute( cursor.execute(
"CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)") "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)")

View File

@ -11,7 +11,7 @@ conn = connect(url="http://localhost:6041",
# create STable # create STable
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute("DROP DATABASE IF EXISTS power", req_id=1) cursor.execute("DROP DATABASE IF EXISTS power", req_id=1)
cursor.execute("CREATE DATABASE power", req_id=2) cursor.execute("CREATE DATABASE power keep 36500", req_id=2)
cursor.execute( cursor.execute(
"CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)", req_id=3) "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)", req_id=3)

View File

@ -6,13 +6,13 @@ conn = taosws.connect("taosws://root:taosdata@localhost:6041")
# ANCHOR: basic # ANCHOR: basic
conn.execute("drop database if exists connwspy") conn.execute("drop database if exists connwspy")
conn.execute("create database if not exists connwspy wal_retention_period 3600") conn.execute("create database if not exists connwspy wal_retention_period 3600 keep 36500 ")
conn.execute("use connwspy") conn.execute("use connwspy")
conn.execute("create table if not exists stb (ts timestamp, c1 int) tags (t1 int)") conn.execute("create table if not exists stb (ts timestamp, c1 int) tags (t1 int)")
conn.execute("create table if not exists tb1 using stb tags (1)") conn.execute("create table if not exists tb1 using stb tags (1)")
conn.execute("insert into tb1 values (now, 1)") conn.execute("insert into tb1 values (now, 1)")
conn.execute("insert into tb1 values (now, 2)") conn.execute("insert into tb1 values (now+1s, 2)")
conn.execute("insert into tb1 values (now, 3)") conn.execute("insert into tb1 values (now+2s, 3)")
r = conn.execute("select * from stb") r = conn.execute("select * from stb")
result = conn.query("select * from stb") result = conn.query("select * from stb")

View File

@ -6,7 +6,7 @@ conn = taosws.connect("taosws://root:taosdata@localhost:6041")
# ANCHOR: basic # ANCHOR: basic
conn.execute("drop database if exists connwspy", req_id=1) conn.execute("drop database if exists connwspy", req_id=1)
conn.execute("create database if not exists connwspy", req_id=2) conn.execute("create database if not exists connwspy keep 36500", req_id=2)
conn.execute("use connwspy", req_id=3) conn.execute("use connwspy", req_id=3)
conn.execute("create table if not exists stb (ts timestamp, c1 int) tags (t1 int)", req_id=4) conn.execute("create table if not exists stb (ts timestamp, c1 int) tags (t1 int)", req_id=4)
conn.execute("create table if not exists tb1 using stb tags (1)", req_id=5) conn.execute("create table if not exists tb1 using stb tags (1)", req_id=5)

View File

@ -4,7 +4,7 @@ import taos
conn = taos.connect() conn = taos.connect()
# Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement. # Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement.
conn.execute("DROP DATABASE IF EXISTS test") conn.execute("DROP DATABASE IF EXISTS test")
conn.execute("CREATE DATABASE test") conn.execute("CREATE DATABASE test keep 36500")
# change database. same as execute "USE db" # change database. same as execute "USE db"
conn.select_db("test") conn.select_db("test")
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)") conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)")

View File

@ -4,7 +4,7 @@ import taos
conn = taos.connect() conn = taos.connect()
# Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement. # Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement.
conn.execute("DROP DATABASE IF EXISTS test", req_id=1) conn.execute("DROP DATABASE IF EXISTS test", req_id=1)
conn.execute("CREATE DATABASE test", req_id=2) conn.execute("CREATE DATABASE test keep 36500", req_id=2)
# change database. same as execute "USE db" # change database. same as execute "USE db"
conn.select_db("test") conn.select_db("test")
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=3) conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=3)

View File

@ -4,7 +4,7 @@ conn = taos.connect()
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute("DROP DATABASE IF EXISTS test") cursor.execute("DROP DATABASE IF EXISTS test")
cursor.execute("CREATE DATABASE test") cursor.execute("CREATE DATABASE test keep 36500")
cursor.execute("USE test") cursor.execute("USE test")
cursor.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)") cursor.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)")

View File

@ -4,7 +4,7 @@ conn = taos.connect()
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute("DROP DATABASE IF EXISTS test", req_id=1) cursor.execute("DROP DATABASE IF EXISTS test", req_id=1)
cursor.execute("CREATE DATABASE test", req_id=2) cursor.execute("CREATE DATABASE test keep 36500", req_id=2)
cursor.execute("USE test", req_id=3) cursor.execute("USE test", req_id=3)
cursor.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=4) cursor.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=4)

View File

@ -160,7 +160,7 @@ def main(infinity):
conn = get_connection() conn = get_connection()
conn.execute("DROP DATABASE IF EXISTS test") conn.execute("DROP DATABASE IF EXISTS test")
conn.execute("CREATE DATABASE IF NOT EXISTS test") conn.execute("CREATE DATABASE IF NOT EXISTS test keep 36500")
conn.execute("CREATE STABLE IF NOT EXISTS test.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) " conn.execute("CREATE STABLE IF NOT EXISTS test.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) "
"TAGS (location BINARY(64), groupId INT)") "TAGS (location BINARY(64), groupId INT)")
conn.close() conn.close()

View File

@ -16,7 +16,7 @@ def get_connection():
def create_database(conn): def create_database(conn):
conn.execute("CREATE DATABASE test") conn.execute("CREATE DATABASE test keep 36500")
conn.execute("USE test") conn.execute("USE test")

View File

@ -5,7 +5,7 @@ LOCATIONS = ['California.SanFrancisco', 'California.LosAngles', 'California.SanD
'California.PaloAlto', 'California.Campbell', 'California.MountainView', 'California.Sunnyvale', 'California.PaloAlto', 'California.Campbell', 'California.MountainView', 'California.Sunnyvale',
'California.SantaClara', 'California.Cupertino'] 'California.SantaClara', 'California.Cupertino']
CREATE_DATABASE_SQL = 'create database if not exists {} keep 365 duration 10 buffer 16 wal_level 1 wal_retention_period 3600' CREATE_DATABASE_SQL = 'create database if not exists {} keep 36500 duration 10 buffer 16 wal_level 1 wal_retention_period 3600'
USE_DATABASE_SQL = 'use {}' USE_DATABASE_SQL = 'use {}'
DROP_TABLE_SQL = 'drop table if exists meters' DROP_TABLE_SQL = 'drop table if exists meters'
DROP_DATABASE_SQL = 'drop database if exists {}' DROP_DATABASE_SQL = 'drop database if exists {}'

View File

@ -15,7 +15,7 @@ def get_connection():
def create_database(conn): def create_database(conn):
# the default precision is ms (microsecond), but we use us(microsecond) here. # the default precision is ms (microsecond), but we use us(microsecond) here.
conn.execute("CREATE DATABASE test precision 'us'") conn.execute("CREATE DATABASE test precision 'us' keep 36500")
conn.execute("USE test") conn.execute("USE test")

View File

@ -71,7 +71,7 @@ def insert_data():
def create_stable(): def create_stable():
conn = taos.connect() conn = taos.connect()
try: try:
conn.execute("CREATE DATABASE power") conn.execute("CREATE DATABASE power keep 36500")
conn.execute("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) " conn.execute("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) "
"TAGS (location BINARY(64), groupId INT)") "TAGS (location BINARY(64), groupId INT)")
finally: finally:

View File

@ -18,7 +18,7 @@ def get_connection() -> taos.TaosConnection:
def create_stable(conn: taos.TaosConnection): def create_stable(conn: taos.TaosConnection):
conn.execute("CREATE DATABASE power") conn.execute("CREATE DATABASE power keep 36500")
conn.execute("USE power") conn.execute("USE power")
conn.execute("CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) " conn.execute("CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) "
"TAGS (location BINARY(64), groupId INT)") "TAGS (location BINARY(64), groupId INT)")

View File

@ -2,7 +2,7 @@ import taos
conn = taos.connect() conn = taos.connect()
conn.execute("DROP DATABASE IF EXISTS test") conn.execute("DROP DATABASE IF EXISTS test")
conn.execute("CREATE DATABASE test") conn.execute("CREATE DATABASE test keep 36500")
conn.select_db("test") conn.select_db("test")
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)") conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)")
# prepare data # prepare data

View File

@ -2,7 +2,7 @@ import taos
conn = taos.connect() conn = taos.connect()
conn.execute("DROP DATABASE IF EXISTS test", req_id=1) conn.execute("DROP DATABASE IF EXISTS test", req_id=1)
conn.execute("CREATE DATABASE test", req_id=2) conn.execute("CREATE DATABASE test keep 36500", req_id=2)
conn.select_db("test") conn.select_db("test")
conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=3) conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=3)
# prepare data # prepare data

View File

@ -3,7 +3,7 @@ import taos
conn = taos.connect() conn = taos.connect()
dbname = "pytest_line" dbname = "pytest_line"
conn.execute("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
conn.execute("create database if not exists %s precision 'us'" % dbname) conn.execute("create database if not exists %s precision 'us' keep 36500" % dbname)
conn.select_db(dbname) conn.select_db(dbname)
lines = [ lines = [

View File

@ -10,9 +10,9 @@ try:
conn.execute("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
if taos.IS_V3: if taos.IS_V3:
conn.execute("create database if not exists %s schemaless 1 precision 'ns'" % dbname) conn.execute("create database if not exists %s schemaless 1 precision 'ns' keep 36500" % dbname)
else: else:
conn.execute("create database if not exists %s update 2 precision 'ns'" % dbname) conn.execute("create database if not exists %s update 2 precision 'ns' keep 36500" % dbname)
conn.select_db(dbname) conn.select_db(dbname)

View File

@ -10,9 +10,9 @@ try:
conn.execute("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
if taos.IS_V3: if taos.IS_V3:
conn.execute("create database if not exists %s schemaless 1 precision 'ns'" % dbname) conn.execute("create database if not exists %s schemaless 1 precision 'ns' keep 36500" % dbname)
else: else:
conn.execute("create database if not exists %s update 2 precision 'ns'" % dbname) conn.execute("create database if not exists %s update 2 precision 'ns' keep 36500" % dbname)
conn.select_db(dbname) conn.select_db(dbname)

View File

@ -10,9 +10,9 @@ try:
conn.execute("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
if taos.IS_V3: if taos.IS_V3:
conn.execute("create database if not exists %s schemaless 1 precision 'ns'" % dbname) conn.execute("create database if not exists %s schemaless 1 precision 'ns' keep 36500" % dbname)
else: else:
conn.execute("create database if not exists %s update 2 precision 'ns'" % dbname) conn.execute("create database if not exists %s update 2 precision 'ns' keep 36500" % dbname)
conn.select_db(dbname) conn.select_db(dbname)

View File

@ -4,7 +4,7 @@ from taos import SmlProtocol, SmlPrecision
conn = taos.connect() conn = taos.connect()
dbname = "pytest_line" dbname = "pytest_line"
conn.execute("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
conn.execute("create database if not exists %s precision 'us'" % dbname) conn.execute("create database if not exists %s precision 'us' keep 36500" % dbname)
conn.select_db(dbname) conn.select_db(dbname)
lines = [ lines = [

View File

@ -4,7 +4,7 @@ from taos import SmlProtocol, SmlPrecision
conn = taos.connect() conn = taos.connect()
dbname = "pytest_line" dbname = "pytest_line"
conn.execute("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
conn.execute("create database if not exists %s precision 'us'" % dbname) conn.execute("create database if not exists %s precision 'us' keep 36500" % dbname)
conn.select_db(dbname) conn.select_db(dbname)
lines = [ lines = [

View File

@ -10,7 +10,7 @@ class SQLWriter:
self._tb_tags = {} self._tb_tags = {}
self._conn = get_connection_func() self._conn = get_connection_func()
self._max_sql_length = self.get_max_sql_length() self._max_sql_length = self.get_max_sql_length()
self._conn.execute("create database if not exists test") self._conn.execute("create database if not exists test keep 36500")
self._conn.execute("USE test") self._conn.execute("USE test")
def get_max_sql_length(self): def get_max_sql_length(self):

View File

@ -10,7 +10,7 @@ db_name = 'test_ws_stmt'
def before(): def before():
taos_conn = taos.connect() taos_conn = taos.connect()
taos_conn.execute("drop database if exists %s" % db_name) taos_conn.execute("drop database if exists %s" % db_name)
taos_conn.execute("create database %s" % db_name) taos_conn.execute("create database %s keep 36500" % db_name)
taos_conn.select_db(db_name) taos_conn.select_db(db_name)
taos_conn.execute("create table t1 (ts timestamp, a int, b float, c varchar(10))") taos_conn.execute("create table t1 (ts timestamp, a int, b float, c varchar(10))")
taos_conn.execute( taos_conn.execute(

View File

@ -9,7 +9,7 @@ import taos
def before_test(db_name): def before_test(db_name):
taos_conn = taos.connect() taos_conn = taos.connect()
taos_conn.execute("drop database if exists %s" % db_name) taos_conn.execute("drop database if exists %s" % db_name)
taos_conn.execute("create database %s" % db_name) taos_conn.execute("create database %s keep 36500" % db_name)
taos_conn.select_db(db_name) taos_conn.select_db(db_name)
taos_conn.execute("create table t1 (ts timestamp, a int, b float, c varchar(10))") taos_conn.execute("create table t1 (ts timestamp, a int, b float, c varchar(10))")
taos_conn.execute( taos_conn.execute(

View File

@ -19,7 +19,7 @@ def get_connection():
def create_database(conn): def create_database(conn):
conn.execute("CREATE DATABASE test") conn.execute("CREATE DATABASE test keep 36500")
conn.execute("USE test") conn.execute("USE test")

View File

@ -7,7 +7,7 @@ def prepare():
conn = taos.connect() conn = taos.connect()
conn.execute("drop topic if exists tmq_assignment_demo_topic") conn.execute("drop topic if exists tmq_assignment_demo_topic")
conn.execute("drop database if exists tmq_assignment_demo_db") conn.execute("drop database if exists tmq_assignment_demo_db")
conn.execute("create database if not exists tmq_assignment_demo_db wal_retention_period 3600") conn.execute("create database if not exists tmq_assignment_demo_db wal_retention_period 3600 keep 36500")
conn.select_db("tmq_assignment_demo_db") conn.select_db("tmq_assignment_demo_db")
conn.execute( conn.execute(
"create table if not exists tmq_assignment_demo_table (ts timestamp, c1 int, c2 float, c3 binary(10)) tags(t1 int)") "create table if not exists tmq_assignment_demo_table (ts timestamp, c1 int, c2 float, c3 binary(10)) tags(t1 int)")

View File

@ -6,7 +6,7 @@ def init_tmq_env(db, topic):
conn = taos.connect() conn = taos.connect()
conn.execute("drop topic if exists {}".format(topic)) conn.execute("drop topic if exists {}".format(topic))
conn.execute("drop database if exists {}".format(db)) conn.execute("drop database if exists {}".format(db))
conn.execute("create database if not exists {} wal_retention_period 3600".format(db)) conn.execute("create database if not exists {} wal_retention_period 3600 keep 36500".format(db))
conn.select_db(db) conn.select_db(db)
conn.execute( conn.execute(
"create stable if not exists stb1 (ts timestamp, c1 int, c2 float, c3 varchar(16)) tags(t1 int, t3 varchar(16))") "create stable if not exists stb1 (ts timestamp, c1 int, c2 float, c3 varchar(16)) tags(t1 int, t3 varchar(16))")

View File

@ -6,7 +6,7 @@ def prepare():
conn = taos.connect() conn = taos.connect()
conn.execute("drop topic if exists tmq_assignment_demo_topic") conn.execute("drop topic if exists tmq_assignment_demo_topic")
conn.execute("drop database if exists tmq_assignment_demo_db") conn.execute("drop database if exists tmq_assignment_demo_db")
conn.execute("create database if not exists tmq_assignment_demo_db wal_retention_period 3600") conn.execute("create database if not exists tmq_assignment_demo_db wal_retention_period 3600 keep 36500")
conn.select_db("tmq_assignment_demo_db") conn.select_db("tmq_assignment_demo_db")
conn.execute( conn.execute(
"create table if not exists tmq_assignment_demo_table (ts timestamp, c1 int, c2 float, c3 binary(10)) tags(t1 int)") "create table if not exists tmq_assignment_demo_table (ts timestamp, c1 int, c2 float, c3 binary(10)) tags(t1 int)")

View File

@ -86,7 +86,7 @@ pip3 install kafka-python
python3 kafka_example_consumer.py python3 kafka_example_consumer.py
# 21 # 21
pip3 install taos-ws-py==0.2.6 pip3 install taos-ws-py==0.3.1
python3 conn_websocket_pandas.py python3 conn_websocket_pandas.py
# 22 # 22