From 30ea2efd028fad059ddc035780e43f13eab9e668 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Sat, 6 Feb 2021 09:39:46 +0000 Subject: [PATCH] [TD-2771] : python taosdemo. refine query. --- tests/examples/python/taosdemo/taosdemo.py | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/examples/python/taosdemo/taosdemo.py b/tests/examples/python/taosdemo/taosdemo.py index b15fc19a38..d55023bdbf 100755 --- a/tests/examples/python/taosdemo/taosdemo.py +++ b/tests/examples/python/taosdemo/taosdemo.py @@ -143,16 +143,17 @@ def query_data_process(cmd: str): user=user, password=password, config=configDir) - print("conn: %s" % str(conn.__class__)) + v_print("conn: %s", str(conn.__class__)) except Exception as e: print("Error: %s" % e.args[0]) sys.exit(1) try: 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: print("Error: %s" % e.args[0]) + conn.close() sys.exit(1) if native: @@ -272,16 +273,17 @@ def insert_func(process: int, thread: int): user=user, password=password, config=configDir) - print("conn: %s" % str(conn.__class__)) + v_print("conn: %s", str(conn.__class__)) except Exception as e: print("Error: %s" % e.args[0]) sys.exit(1) try: 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: print("Error: %s" % e.args[0]) + conn.close() sys.exit(1) v_print("numOfRec %d:", numOfRec) @@ -331,10 +333,9 @@ def insert_func(process: int, thread: int): if measure: exec_end_time = datetime.datetime.now() exec_delta = exec_end_time - exec_start_time - print( - "%s, %d" % - (time.strftime('%X'), - exec_delta.microseconds)) + v_print( + "consume %d microseconds", + exec_delta.microseconds) v_print("cmd: %s, length:%d", cmd, len(cmd)) @@ -489,7 +490,7 @@ if __name__ == "__main__": threads = 1 insertOnly = False autosubtable = False - queryCmd = "DEFAULT" + queryCmd = "NO" outOfOrder = 0 rateOOOO = 0 deleteMethod = 0 @@ -541,7 +542,7 @@ if __name__ == "__main__": '\t-M, --stable flag, Use super table. Default is no') print( '\t-s, --stbname stable_prefix, STable prefix name. Default is \'st\'') - print('\t-Q, --query 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( '\t-T, --threads num_of_threads, The number of threads. Default is 1.') print( @@ -685,16 +686,17 @@ if __name__ == "__main__": user=user, password=password, config=configDir) - print("conn: %s" % str(conn.__class__)) + v_print("conn: %s", str(conn.__class__)) except Exception as e: print("Error: %s" % e.args[0]) sys.exit(1) try: 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: print("Error: %s" % e.args[0]) + conn.close() sys.exit(1) # drop data only if delete method be set @@ -769,7 +771,6 @@ if __name__ == "__main__": else: end = begin + quotient pool.apply_async(insert_data_process, args=(lock, i, begin, end,)) -# pool.apply_async(text, args=(lock, i, begin, end,)) pool.close() pool.join() -- GitLab