Retrieving and Displaying Data from a SQLite Database

In this tutorial we will look at how you retrieve and display data from a node-red database.

The tutorial uses data I collect for monitoring several of my websites.

The data consists of a

  • timestamp
  • site name
  • page load speed

We have a web form that lets us select a website a time range and a page speed range and is shown below:

site-speed-table

The results are displayed in a table.

The flow is shown below:

site-speed-flow

Besides the dashboard nodes there are two function nodes.

The store data node builds the database query based on the user selection and the convert time function converts the timestamp from a millisecond time to a human readable time before displaying it.

 

Notes about the store data node:

  • Stores data in a context variable called data until you click submit
  • The time is stored in milliseconds and the select time drop downs use milliseconds
  • The results are limited to 100 results and ordered by timestamp in descending order. The query is shown below:

 

data-query

Data from the SQL node is passed to the convert time function which changes the time to a more user friendly form before sending it to the display.

Video Reading Data from a SQL Database

Related tutorials and Resources:

Click to rate this post!
[Total: 0 Average: 0]

Leave a Reply

Your email address will not be published. Required fields are marked *