From f4c1ad0fdea1e5f6340c754733df6743f5318d6b Mon Sep 17 00:00:00 2001 From: menshibin Date: Thu, 15 Aug 2024 13:06:47 +0800 Subject: [PATCH] modify exec error --- docs/examples/python/schemaless_ws.py | 13 +++++++------ docs/examples/python/stmt_native.py | 4 ++-- docs/examples/python/stmt_ws.py | 4 ++-- docs/examples/python/tmq_native.py | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/docs/examples/python/schemaless_ws.py b/docs/examples/python/schemaless_ws.py index 3c41d1768b..39de55393d 100644 --- a/docs/examples/python/schemaless_ws.py +++ b/docs/examples/python/schemaless_ws.py @@ -1,19 +1,21 @@ import taosws +host = "localhost" +port = 6041 def prepare(): conn = None try: conn = taosws.connect(user="root", password="taosdata", - host="localhost", - port=6041) + host=host, + port=port) # create database rowsAffected = conn.execute(f"CREATE DATABASE IF NOT EXISTS power") assert rowsAffected == 0 except Exception as err: - print(f"Failed to create db and table, err:{err}") + print(f"Failed to create db and table, db addrr:{host}:{port} ; ErrMessage:{err}") raise err finally: if conn: @@ -32,8 +34,7 @@ def schemaless_insert(): jsonDemo = [ '{"metric": "metric_json","timestamp": 1626846400,"value": 10.3, "tags": {"groupid": 2, "location": "California.SanFrancisco", "id": "d1001"}}' ] - host = "localhost" - port = 6041 + try: conn = taosws.connect(user="root", password="taosdata", @@ -76,6 +77,6 @@ def schemaless_insert(): if __name__ == "__main__": try: prepare() - schemaless_insert + schemaless_insert() except Exception as err: print(f"Failed to insert data with schemaless, err:{err}") diff --git a/docs/examples/python/stmt_native.py b/docs/examples/python/stmt_native.py index 16975d6895..a1af7d1dd7 100644 --- a/docs/examples/python/stmt_native.py +++ b/docs/examples/python/stmt_native.py @@ -7,8 +7,8 @@ numOfRow = 10 conn = None stmt = None -host="localhost", -port=6030, +host="localhost" +port=6030 try: conn = taos.connect( user="root", diff --git a/docs/examples/python/stmt_ws.py b/docs/examples/python/stmt_ws.py index 74f071fde1..45d9222315 100644 --- a/docs/examples/python/stmt_ws.py +++ b/docs/examples/python/stmt_ws.py @@ -13,8 +13,8 @@ port=6041 try: conn = taosws.connect(user="root", password="taosdata", - host="localhost", - port=6041) + host=host, + port=port) conn.execute("CREATE DATABASE IF NOT EXISTS power") conn.execute("USE power") diff --git a/docs/examples/python/tmq_native.py b/docs/examples/python/tmq_native.py index 8181e1c2db..22a9b805bc 100644 --- a/docs/examples/python/tmq_native.py +++ b/docs/examples/python/tmq_native.py @@ -50,7 +50,7 @@ from taos.tmq import Consumer def create_consumer(): host = "localhost" - port = 6030 + port = "6030" groupId = "group1" clientId = "1" try: