为支持各种不同类型平台的开发,TDengine提供符合REST设计标准的API,即RESTful API。为最大程度降低学习成本,不同于其他数据库RESTful API的设计方法,TDengine直接通过HTTP POST 请求BODY中包含的SQL语句来操作数据库,仅需要一个URL。RESTful连接器的使用参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1965.html)。
为支持各种不同类型平台的开发,TDengine 提供符合 REST 设计标准的 API,即 RESTful API。为最大程度降低学习成本,不同于其他数据库 RESTful API 的设计方法,TDengine 直接通过 HTTP POST 请求 BODY 中包含的 SQL 语句来操作数据库,仅需要一个 URL。RESTful 连接器的使用参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1965.html)。
tdSql.query("select count(*) from (select * from dev_001) session(ts,5a)")
tdSql.checkRows(15)
tdSql.checkData(0,1,2)
# session(ts,1s)
tdSql.query("select count(*) from dev_001 session(ts,1s)")
tdSql.checkRows(12)
tdSql.checkData(0,1,5)
# session(ts,1s) main query
tdSql.query("select count(*) from (select * from dev_001) session(ts,1s)")
tdSql.checkRows(12)
tdSql.checkData(0,1,5)
tdSql.query("select count(*) from dev_001 session(ts,1000a)")
tdSql.checkRows(12)
tdSql.checkData(0,1,5)
tdSql.query("select count(*) from (select * from dev_001) session(ts,1000a)")
tdSql.checkRows(12)
tdSql.checkData(0,1,5)
# session(ts,1m)
tdSql.query("select count(*) from dev_001 session(ts,1m)")
tdSql.checkRows(9)
tdSql.checkData(0,1,8)
# session(ts,1m)
tdSql.query("select count(*) from (select * from dev_001) session(ts,1m)")
tdSql.checkRows(9)
tdSql.checkData(0,1,8)
# session(ts,1h)
tdSql.query("select count(*) from dev_001 session(ts,1h)")
tdSql.checkRows(6)
tdSql.checkData(0,1,11)
# session(ts,1h)
tdSql.query("select count(*) from (select * from dev_001) session(ts,1h)")
tdSql.checkRows(6)
tdSql.checkData(0,1,11)
# session(ts,1d)
tdSql.query("select count(*) from dev_001 session(ts,1d)")
tdSql.checkRows(4)
tdSql.checkData(0,1,13)
# session(ts,1d)
tdSql.query("select count(*) from (select * from dev_001) session(ts,1d)")
tdSql.checkRows(4)
tdSql.checkData(0,1,13)
# session(ts,1w)
tdSql.query("select count(*) from dev_001 session(ts,1w)")
tdSql.checkRows(2)
tdSql.checkData(0,1,15)
# session(ts,1w)
tdSql.query("select count(*) from (select * from dev_001) session(ts,1w)")
tdSql.checkRows(2)
tdSql.checkData(0,1,15)
# session with where
tdSql.query("select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1),spread(tagtype),stddev(tagtype),percentile(tagtype,0) from dev_001 where ts <'2020-05-20 0:0:0' session(ts,1d)")
tdSql.checkRows(2)
tdSql.checkData(0,1,13)
tdSql.checkData(0,2,1)
...
...
@@ -97,6 +132,20 @@ class TDTestCase:
tdSql.checkData(0,11,1)
tdSql.checkData(1,11,14)
# session with where main
tdSql.query("select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1) from (select * from dev_001 where ts <'2020-05-20 0:0:0') session(ts,1d)")
sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol
sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc