As Reading API
ℹ️
For the examples, create a table and insert data with the following SQL statements.
CREATE TAG TABLE IF NOT EXISTS EXAMPLE (
NAME VARCHAR(20) PRIMARY KEY,
TIME DATETIME BASETIME,
VALUE DOUBLE SUMMARIZED);
INSERT INTO EXAMPLE VALUES('TAG0', TO_DATE('2021-08-12'), 10);
INSERT INTO EXAMPLE VALUES('TAG0', TO_DATE('2021-08-13'), 11);
CSV format
Save tql file
Save the code below as output-csv.tql
.
SQL( `select * from example limit 2` )
CSV()
Client GET request
Invoke the tql file with curl command.
$ curl http://127.0.0.1:5654/db/tql/output-csv.tql
TAG0,1628694000000000000,10
TAG0,1628780400000000000,11
JSON format
Save tql file
Save the code below as output-json.tql
.
SQL( `select * from example limit 2` )
JSON()
Client GET request
Invoke the tql file with curl command.
$ curl http://127.0.0.1:5654/db/tql/output-json.tql
{
"data": {
"columns": [ "NAME", "TIME", "VALUE" ],
"types": [ "string", "datetime", "double" ],
"rows": [
[ "TAG0", 1628694000000000000, 10 ],
[ "TAG0", 1628780400000000000, 11 ]
]
},
"success": true,
"reason": "success",
"elapse": "770.078µs"
}
JSON format with transpose()
Save tql file
Save the code below as output-json.tql
.
SQL( `select * from example limit 2` )
JSON( transpose(true) )
Client GET request
Invoke the tql file with curl command.
$ curl http://127.0.0.1:5654/db/tql/output-json.tql
{
"data": {
"columns": [ "NAME", "TIME", "VALUE" ],
"types": [ "string", "datetime", "double" ],
"cols": [
[ "TAG0", "TAG0" ],
[ 1628694000000000000, 1628780400000000000 ],
[ 10, 11 ]
]
},
"success": true,
"reason": "success",
"elapse": "718.625µs"
}
MARKDOWN format
Save tql file
Save the code below as output-markdown.tql
.
SQL( `select * from example limit 2` )
MARKDOWN()
Client GET request
Invoke the tql file with curl command.
$ curl http://127.0.0.1:5654/db/tql/output-markdown.tql
|NAME|TIME|VALUE|
|:-----|:-----|:-----|
|TAG0|1628694000000000000|10.000000|
|TAG0|1628780400000000000|11.000000|
MARKDOWN format with html()
Save tql file
Save the code below as output-markdown.tql
.
SQL( `select * from example limit 2` )
MARKDOWN( html(true) )
Client GET request
Invoke the tql file with curl command.
$ curl http://127.0.0.1:5654/db/tql/output-markdown.tql
<div><table>
<thead>
<tr>
<th align="left">NAME</th>
<th align="left">TIME</th>
<th align="left">VALUE</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">TAG0</td>
<td align="left">1628694000000000000</td>
<td align="left">10.000000</td>
</tr>
<tr>
<td align="left">TAG0</td>
<td align="left">1628780400000000000</td>
<td align="left">11.000000</td>
</tr>
</tbody>
</table>
</div>
CHART format
Save tql file
Save the code below as output-chart.tql
.
SQL( `select * from example limit 2` )
CHART_BAR()
Client GET request
Open web browser with http://127.0.0.1:5654/db/tql/output-chart.tql

CHART types
Last updated on