正式发布前:2024-07-17
runSql(
"SELECT Name as label, District as district, Population as value FROM world.city WHERE Name = 'Kabul' ",
(res: ResultSetRows) => {
print(res);
}
);
输出为
[ { "label": "Kabul", "district": "Kabol", "value": 1780000 } ]
const graphData = [];
runSqlIterative(
"SELECT rating as label , count(rating) as value FROM sakila.film " +
"GROUP BY rating",
(res: IResultSetData) => {
if (res.rows) {
res.rows.forEach((row, index) => {
graphData.push({
label: row[1] as string,
value: 25,
});
});
}
if (res.requestState.type === "OK") {
print(res);
}
}
);
输出为
{ "requestState": { "type": "OK", "msg": "Full result set consisting of 5 rows transferred." }, "requestId": "6ee28aa2-2727-42d9-2bd9-d60f8d4abb64", "rows": [ [ "PG", 194 ], [ "G", 178 ], [ "NC-17", 210 ], [ "PG-13", 223 ], [ "R", 195 ] ], "columns": [ { "name": "label", "type": "ENUM", "length": 20 }, { "name": "value", "type": "INTEGER", "length": 21 } ], "done": true, "totalRowCount": 5, "executionTime": 0.0009739398956298828 }