SQLite cheatsheet
Count rows in the table
In this example a SQLite query is used to count the rows in the avatar table.
# count rows in a table
datasources:
row_count:
type: datasource.sqlite
options:
provider: DATA_PROVIDER_DYNAMIC
entities:
- default/avatar
query: |
SELECT COUNT(*) AS row_count
FROM [default/avatar] title: Number of rows
description: Use SQLite query to count the number of rows in the Avatar dynamic data table
type: jig.default
header:
type: component.jig-header
options:
height: medium
children:
type: component.image
options:
source:
uri: https://images.unsplash.com/photo-1489875347897-49f64b51c1f8?auto=format&fit=crop&q=60&w=800&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MXx8c3FsJTIwcXVlcnl8ZW58MHx8MHx8fDA%3D
# count rows in a table
datasources:
row_count:
type: datasource.sqlite
options:
provider: DATA_PROVIDER_DYNAMIC
entities:
- default/avatar
query: |
SELECT COUNT(*) AS row_count
FROM [default/avatar]
children:
- type: component.entity
options:
children:
- type: component.entity-field
options:
label: Number of rows
value: [email protected]_count.row_countConverting dates
Here is an example of using a SQLite query to convert dates in a dynamic data table.

Joining data from tables and using subquery
Using a SQLite query, one can join data from different tables by utilizing subqueries. This allows for the combination of information from multiple tables based on specified conditions. By employing subqueries, one can retrieve and manipulate data ensuring accurate and comprehensive results. Below is an example of joining tables and then using a subquery.


Joining tables
Often you want to use data in your solution but the data is stored in different tables. Use a SQLite query to join the data from tables and extract the exact information you want to use. When joining two tables there must be the same identifier in both tables. In the example below both tables has a $.date column. Result: The result of the example below is date: 5 finished_date: 5.11


JSON array length
The query below provides the JSON array length from a table called battles.

Last updated
Was this helpful?