未验证 提交 00bc53bc 编写于 作者: B Bo Ding 提交者: GitHub

replace 'exec' with 'execute' (#8891)

上级 ea155cd5
...@@ -51,7 +51,7 @@ conn.close() ...@@ -51,7 +51,7 @@ conn.close()
import taos import taos
conn = taos.connect() conn = taos.connect()
conn.exec("create database if not exists pytest") conn.execute("create database if not exists pytest")
result = conn.query("show databases") result = conn.query("show databases")
num_of_fields = result.field_count num_of_fields = result.field_count
...@@ -60,7 +60,7 @@ for field in result.fields: ...@@ -60,7 +60,7 @@ for field in result.fields:
for row in result: for row in result:
print(row) print(row)
result.close() result.close()
conn.exec("drop database pytest") conn.execute("drop database pytest")
conn.close() conn.close()
``` ```
...@@ -136,11 +136,11 @@ from taos import * ...@@ -136,11 +136,11 @@ from taos import *
conn = connect() conn = connect()
dbname = "pytest_taos_stmt" dbname = "pytest_taos_stmt"
conn.exec("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
conn.exec("create database if not exists %s" % dbname) conn.execute("create database if not exists %s" % dbname)
conn.select_db(dbname) conn.select_db(dbname)
conn.exec( conn.execute(
"create table if not exists log(ts timestamp, bo bool, nil tinyint, \ "create table if not exists log(ts timestamp, bo bool, nil tinyint, \
ti tinyint, si smallint, ii int, bi bigint, tu tinyint unsigned, \ ti tinyint, si smallint, ii int, bi bigint, tu tinyint unsigned, \
su smallint unsigned, iu int unsigned, bu bigint unsigned, \ su smallint unsigned, iu int unsigned, bu bigint unsigned, \
...@@ -196,11 +196,11 @@ from taos import * ...@@ -196,11 +196,11 @@ from taos import *
conn = connect() conn = connect()
dbname = "pytest_taos_stmt" dbname = "pytest_taos_stmt"
conn.exec("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
conn.exec("create database if not exists %s" % dbname) conn.execute("create database if not exists %s" % dbname)
conn.select_db(dbname) conn.select_db(dbname)
conn.exec( conn.execute(
"create table if not exists log(ts timestamp, bo bool, nil tinyint, \ "create table if not exists log(ts timestamp, bo bool, nil tinyint, \
ti tinyint, si smallint, ii int, bi bigint, tu tinyint unsigned, \ ti tinyint, si smallint, ii int, bi bigint, tu tinyint unsigned, \
su smallint unsigned, iu int unsigned, bu bigint unsigned, \ su smallint unsigned, iu int unsigned, bu bigint unsigned, \
...@@ -249,12 +249,12 @@ import taos ...@@ -249,12 +249,12 @@ import taos
conn = taos.connect() conn = taos.connect()
dbname = "pytest_taos_subscribe_callback" dbname = "pytest_taos_subscribe_callback"
conn.exec("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
conn.exec("create database if not exists %s" % dbname) conn.execute("create database if not exists %s" % dbname)
conn.select_db(dbname) conn.select_db(dbname)
conn.exec("create table if not exists log(ts timestamp, n int)") conn.execute("create table if not exists log(ts timestamp, n int)")
for i in range(10): for i in range(10):
conn.exec("insert into log values(now, %d)" % i) conn.execute("insert into log values(now, %d)" % i)
sub = conn.subscribe(True, "test", "select * from log", 1000) sub = conn.subscribe(True, "test", "select * from log", 1000)
print("# consume from begin") print("# consume from begin")
...@@ -263,14 +263,14 @@ for ts, n in sub.consume(): ...@@ -263,14 +263,14 @@ for ts, n in sub.consume():
print("# consume new data") print("# consume new data")
for i in range(5): for i in range(5):
conn.exec("insert into log values(now, %d)(now+1s, %d)" % (i, i)) conn.execute("insert into log values(now, %d)(now+1s, %d)" % (i, i))
result = sub.consume() result = sub.consume()
for ts, n in result: for ts, n in result:
print(ts, n) print(ts, n)
print("# consume with a stop condition") print("# consume with a stop condition")
for i in range(10): for i in range(10):
conn.exec("insert into log values(now, %d)" % int(random() * 10)) conn.execute("insert into log values(now, %d)" % int(random() * 10))
result = sub.consume() result = sub.consume()
try: try:
ts, n = next(result) ts, n = next(result)
...@@ -284,7 +284,7 @@ for i in range(10): ...@@ -284,7 +284,7 @@ for i in range(10):
sub.close() sub.close()
conn.exec("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
conn.close() conn.close()
``` ```
...@@ -311,23 +311,23 @@ def test_subscribe_callback(conn): ...@@ -311,23 +311,23 @@ def test_subscribe_callback(conn):
# type: (TaosConnection) -> None # type: (TaosConnection) -> None
dbname = "pytest_taos_subscribe_callback" dbname = "pytest_taos_subscribe_callback"
try: try:
conn.exec("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
conn.exec("create database if not exists %s" % dbname) conn.execute("create database if not exists %s" % dbname)
conn.select_db(dbname) conn.select_db(dbname)
conn.exec("create table if not exists log(ts timestamp, n int)") conn.execute("create table if not exists log(ts timestamp, n int)")
print("# subscribe with callback") print("# subscribe with callback")
sub = conn.subscribe(False, "test", "select * from log", 1000, subscribe_callback) sub = conn.subscribe(False, "test", "select * from log", 1000, subscribe_callback)
for i in range(10): for i in range(10):
conn.exec("insert into log values(now, %d)" % i) conn.execute("insert into log values(now, %d)" % i)
time.sleep(0.7) time.sleep(0.7)
sub.close() sub.close()
conn.exec("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
conn.close() conn.close()
except Exception as err: except Exception as err:
conn.exec("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
conn.close() conn.close()
raise err raise err
...@@ -374,10 +374,10 @@ def test_stream(conn): ...@@ -374,10 +374,10 @@ def test_stream(conn):
# type: (TaosConnection) -> None # type: (TaosConnection) -> None
dbname = "pytest_taos_stream" dbname = "pytest_taos_stream"
try: try:
conn.exec("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
conn.exec("create database if not exists %s" % dbname) conn.execute("create database if not exists %s" % dbname)
conn.select_db(dbname) conn.select_db(dbname)
conn.exec("create table if not exists log(ts timestamp, n int)") conn.execute("create table if not exists log(ts timestamp, n int)")
result = conn.query("select count(*) from log interval(5s)") result = conn.query("select count(*) from log interval(5s)")
assert result.field_count == 2 assert result.field_count == 2
...@@ -386,13 +386,13 @@ def test_stream(conn): ...@@ -386,13 +386,13 @@ def test_stream(conn):
stream = conn.stream("select count(*) from log interval(5s)", stream_callback, param=byref(counter)) stream = conn.stream("select count(*) from log interval(5s)", stream_callback, param=byref(counter))
for _ in range(0, 20): for _ in range(0, 20):
conn.exec("insert into log values(now,0)(now+1s, 1)(now + 2s, 2)") conn.execute("insert into log values(now,0)(now+1s, 1)(now + 2s, 2)")
time.sleep(2) time.sleep(2)
stream.close() stream.close()
conn.exec("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
conn.close() conn.close()
except Exception as err: except Exception as err:
conn.exec("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
conn.close() conn.close()
raise err raise err
...@@ -408,8 +408,8 @@ import taos ...@@ -408,8 +408,8 @@ import taos
conn = taos.connect() conn = taos.connect()
dbname = "pytest_line" dbname = "pytest_line"
conn.exec("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
conn.exec("create database if not exists %s precision 'us'" % dbname) conn.execute("create database if not exists %s precision 'us'" % dbname)
conn.select_db(dbname) conn.select_db(dbname)
lines = [ lines = [
...@@ -431,7 +431,7 @@ for row in result: ...@@ -431,7 +431,7 @@ for row in result:
result.close() result.close()
conn.exec("drop database if exists %s" % dbname) conn.execute("drop database if exists %s" % dbname)
conn.close() conn.close()
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册