For the python connector of the TDengine database, I want to get the query result instead of knowing whether it was successfully executed or not. I just want to fetch the result, which api should I use?
I used execute
before but it only returns 1
for success and other errors when failed.
Asked
Active
Viewed 43 times
0

Jackson
- 9
- 4
1 Answers
0
there are some examples in tdengine's githup repos, the links is https://github.com/taosdata/TDengine/tree/develop/tests/examples/python
# query data and return data in the form of list
try:
c1.execute('select * from db.t')
except Exception as err:
conn.close()
raise(err)
# Column names are in c1.description list
cols = c1.description
# Use fetchall to fetch data in a list
data = c1.fetchall()
for col in data:
print(col)
print('Another query method ')
try:
c1.execute('select * from db.t')
except Exception as err:
conn.close()
raise(err)
# Use iterator to go through the retreived data
for col in c1:
print(col)
conn.close()
I hope these can help you.

DDDBA
- 11
- 2