对于TDengine数据库的python连接器,我想得到查询结果而不是知道是否执行成功。我只想获取结果,我应该使用哪个 api?
我以前用过execute
,但它只1
在失败时返回成功和其他错误。
问问题
29 次
1 回答
1
tdengine 的 githup repos 中有一些例子,链接是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()
我希望这些可以帮助你。
于 2021-08-14T13:26:06.743 回答