TDengine/docs/examples/python/reqid_rest.py

19 lines
556 B
Python
Raw Normal View History

2024-08-02 18:51:12 +00:00
import taosrest
client = None
2024-08-12 06:13:31 +00:00
url="http://localhost:6041"
2024-08-12 12:56:20 +00:00
reqId = 3
2024-08-02 18:51:12 +00:00
try:
2024-08-12 06:13:31 +00:00
client = taosrest.RestClient(url=url,
2024-08-02 18:51:12 +00:00
user="root",
password="taosdata",
timeout=30)
2024-08-12 06:13:31 +00:00
result = client.sql(f"SELECT ts, current, location FROM power.meters limit 100", reqId)
if result["data"]:
for row in result["data"]:
print(f"ts: {row[0]}, current: {row[1]}, location: {row[2]}")
2024-08-02 18:51:12 +00:00
except Exception as err:
2024-08-12 11:33:50 +00:00
print(f"Failed to execute sql with reqId:{reqId}, url:{url} ; ErrMessage:{err}")