TDengine/docs/examples/python/reqid_ws.py

22 lines
437 B
Python
Raw Normal View History

2024-08-02 18:51:12 +00:00
import taosws
conn = None
try:
conn = taosws.connect(
user="root",
password="taosdata",
host="localhost",
port=6041,
)
2024-08-03 13:58:17 +00:00
result = conn.query_with_req_id("SELECT ts, current, location FROM power.meters limit 100", req_id=1)
2024-08-02 18:51:12 +00:00
for row in result:
print(row)
except Exception as err:
2024-08-03 13:58:17 +00:00
print(f"Failed to execute sql with reqId, err:{err}")
2024-08-02 18:51:12 +00:00
finally:
if conn:
conn.close()