Skip to main content

TagoSQL

TagoSQL lets you ask a question about your data and get back a clean table of answers. Instead of pulling raw data and filtering it yourself, you write a few lines that say which device, which variable, which period, and how many rows you want. TagoIO does the work and returns exactly those rows.

info

Every query is read-only and limited to your own profile. A query can never reach data that is not yours, and it can never change anything.

TagoSQL query editor with the Tables panel and the results grid

Your first query​

Copy this, replace DEVICE_ID with the id of one of your devices, and run it. You get that device's last 10 readings.

SELECT variable, value, time
FROM device('DEVICE_ID') AS d
ORDER BY time DESC
LIMIT 10

You can find a device id on the device page in TagoIO, or let the query editor list your devices for you.

Where to use it​

ContextSupport
AdminYes: write, save, and run queries with your profile token.
AnalysisYes: run a saved query when an Access Management policy grants it Execute.
TagoRUNYes: Run users run a saved query through the same kind of grant. Custom widgets read data this way.
Custom DashboardYes: list and run saved queries from the shell over the postMessage SQL bridge.
TagoIO APIYes: the /sql routes create, manage, and execute queries.

What you can build with it​

  • Dashboards. Feed a table or chart widget with rows that are already filtered, sorted, and summed, so the widget only has to draw them.
  • Reports. Answer questions like "how many alarms did each site raise last month" in one query instead of exporting data and working on it afterwards.
  • Fleet views. Show the last reading of every device carrying a tag, such as the newest temperature for all your sensors, in a single request.
  • Portals and applications. Save a query once and let an analysis, a custom widget, or a TagoRUN portal run it by id.

How it works​

  1. Write the query. Start from the examples in Getting started and change the device, variable, or period.
  2. Save it. A saved query is a resource on your profile with a name, a version history, and its own settings. See Queries.
  3. Execute it whenever you need the data, from a widget, an analysis, or your own application. See Executing Queries.

Next steps​