提交 30ea2efd 编写于 作者: sangshuduo's avatar sangshuduo

[TD-2771] <feature>: python taosdemo. refine query.

上级 b1c6a7d4
...@@ -143,16 +143,17 @@ def query_data_process(cmd: str): ...@@ -143,16 +143,17 @@ def query_data_process(cmd: str):
user=user, user=user,
password=password, password=password,
config=configDir) config=configDir)
print("conn: %s" % str(conn.__class__)) v_print("conn: %s", str(conn.__class__))
except Exception as e: except Exception as e:
print("Error: %s" % e.args[0]) print("Error: %s" % e.args[0])
sys.exit(1) sys.exit(1)
try: try:
cursor = conn.cursor() cursor = conn.cursor()
print("cursor:%d %s" % (id(cursor), str(cursor.__class__))) v_print("cursor:%d %s", id(cursor), str(cursor.__class__))
except Exception as e: except Exception as e:
print("Error: %s" % e.args[0]) print("Error: %s" % e.args[0])
conn.close()
sys.exit(1) sys.exit(1)
if native: if native:
...@@ -272,16 +273,17 @@ def insert_func(process: int, thread: int): ...@@ -272,16 +273,17 @@ def insert_func(process: int, thread: int):
user=user, user=user,
password=password, password=password,
config=configDir) config=configDir)
print("conn: %s" % str(conn.__class__)) v_print("conn: %s", str(conn.__class__))
except Exception as e: except Exception as e:
print("Error: %s" % e.args[0]) print("Error: %s" % e.args[0])
sys.exit(1) sys.exit(1)
try: try:
cursor = conn.cursor() cursor = conn.cursor()
print("cursor:%d %s" % (id(cursor), str(cursor.__class__))) v_print("cursor:%d %s", id(cursor), str(cursor.__class__))
except Exception as e: except Exception as e:
print("Error: %s" % e.args[0]) print("Error: %s" % e.args[0])
conn.close()
sys.exit(1) sys.exit(1)
v_print("numOfRec %d:", numOfRec) v_print("numOfRec %d:", numOfRec)
...@@ -331,10 +333,9 @@ def insert_func(process: int, thread: int): ...@@ -331,10 +333,9 @@ def insert_func(process: int, thread: int):
if measure: if measure:
exec_end_time = datetime.datetime.now() exec_end_time = datetime.datetime.now()
exec_delta = exec_end_time - exec_start_time exec_delta = exec_end_time - exec_start_time
print( v_print(
"%s, %d" % "consume %d microseconds",
(time.strftime('%X'), exec_delta.microseconds)
exec_delta.microseconds))
v_print("cmd: %s, length:%d", cmd, len(cmd)) v_print("cmd: %s, length:%d", cmd, len(cmd))
...@@ -489,7 +490,7 @@ if __name__ == "__main__": ...@@ -489,7 +490,7 @@ if __name__ == "__main__":
threads = 1 threads = 1
insertOnly = False insertOnly = False
autosubtable = False autosubtable = False
queryCmd = "DEFAULT" queryCmd = "NO"
outOfOrder = 0 outOfOrder = 0
rateOOOO = 0 rateOOOO = 0
deleteMethod = 0 deleteMethod = 0
...@@ -541,7 +542,7 @@ if __name__ == "__main__": ...@@ -541,7 +542,7 @@ if __name__ == "__main__":
'\t-M, --stable flag, Use super table. Default is no') '\t-M, --stable flag, Use super table. Default is no')
print( print(
'\t-s, --stbname <stable prefix> stable_prefix, STable prefix name. Default is \'st\'') '\t-s, --stbname <stable prefix> stable_prefix, STable prefix name. Default is \'st\'')
print('\t-Q, --query <DEFAULT | NO | command> query, Execute query command. set \'DEFAULT\' means select * from each table') print('\t-Q, --query [NO|EACHTB|command] query, Execute query command. set \'EACHTB\' means select * from each table')
print( print(
'\t-T, --threads <number> num_of_threads, The number of threads. Default is 1.') '\t-T, --threads <number> num_of_threads, The number of threads. Default is 1.')
print( print(
...@@ -685,16 +686,17 @@ if __name__ == "__main__": ...@@ -685,16 +686,17 @@ if __name__ == "__main__":
user=user, user=user,
password=password, password=password,
config=configDir) config=configDir)
print("conn: %s" % str(conn.__class__)) v_print("conn: %s", str(conn.__class__))
except Exception as e: except Exception as e:
print("Error: %s" % e.args[0]) print("Error: %s" % e.args[0])
sys.exit(1) sys.exit(1)
try: try:
cursor = conn.cursor() cursor = conn.cursor()
print("cursor:%d %s" % (id(cursor), str(cursor.__class__))) v_print("cursor:%d %s", id(cursor), str(cursor.__class__))
except Exception as e: except Exception as e:
print("Error: %s" % e.args[0]) print("Error: %s" % e.args[0])
conn.close()
sys.exit(1) sys.exit(1)
# drop data only if delete method be set # drop data only if delete method be set
...@@ -769,7 +771,6 @@ if __name__ == "__main__": ...@@ -769,7 +771,6 @@ if __name__ == "__main__":
else: else:
end = begin + quotient end = begin + quotient
pool.apply_async(insert_data_process, args=(lock, i, begin, end,)) pool.apply_async(insert_data_process, args=(lock, i, begin, end,))
# pool.apply_async(text, args=(lock, i, begin, end,))
pool.close() pool.close()
pool.join() pool.join()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册