Data Queries - Complete Guide

๐ Build and Execute Queriesโ
SQL Queries ยท Parameters ยท Testing ยท Caching ยท Execution
๐ Table of Contentsโ
- Overview
- Creating a Data Query
- Query Configuration
- Query Parameters
- Query Execution
- Testing Queries
- Query Results
- Advanced Features
- Examples
Overviewโ
Data Queries are reusable query definitions that execute against your configured datasources. They are the foundation for:
- โ Dashboard widgets
- โ Workflow automation
- โ Data transformations
- โ API endpoints
- โ Scheduled jobs
Key Featuresโ
- Native SQL - Write queries in PostgreSQL dialect
- Parameterized Queries - Use dynamic variables
- Query Testing - Test before saving
- Result Caching - Optimize performance
- Run on Load - Auto-execute options
- AI Assistance - Generate queries with AI
- Bulk Operations - Create multiple queries
Query Typesโ
| Query Type | Description | Use Case |
|---|---|---|
| SELECT | Retrieve data | Dashboards, reports |
| INSERT | Create records | Form submissions |
| UPDATE | Modify records | Data updates |
| DELETE | Remove records | Cleanup operations |
| UPSERT | Insert or update | Sync operations |
Creating a Data Queryโ
Step-by-Step Guideโ
- Navigate to Data Queries in sidebar
- Click "Create Data Query" button
- Select datasource from dropdown
- Configure query settings
- Write SQL query
- Define parameters (if any)
- Test the query
- Save for reuse
Required Fieldsโ
| Field | Type | Required | Description |
|---|---|---|---|
| Query Title | String | โ Yes | Unique name for the query |
| Datasource | Datasource | โ Yes | Database connection to use |
| Query Type | String | โ Yes | query (SQL) or gui (visual) |
| Query | String | โ Yes | SQL statement to execute |
Optional Fieldsโ
| Field | Type | Default | Description |
|---|---|---|---|
| Run on Load | Boolean | false | Execute automatically when loaded |
| Description | String | - | Query documentation |
| Tags | Array | [] | Organizational tags |
| Timeout | Integer | 300s | Query execution timeout |
Query Configurationโ
Query Titleโ
Purpose: Identify this query in lists and dropdowns.
Validation:
- Required: Yes
- Min Length: 1 character
- Max Length: 255 characters
Best Practices:
โ
Good: "GetActiveUsers"
โ
Good: "CreateNewOrder"
โ
Good: "UpdateProductInventory"
โ Bad: "Query1"
โ Bad: "test"
Datasource Selectionโ
Purpose: Choose which database connection to use.
Options:
- Any configured PostgreSQL datasource
- REST API datasource (for API calls)
- Datasource dropdown with refresh button
How to Select:
- Click datasource dropdown
- Select from available datasources
- Click refresh icon if datasource not showing
- Datasource loads with connection details
Query Typeโ
Purpose: Choose query input method.
Options:
| Type | Value | Description |
|---|---|---|
| Raw SQL | query | Write SQL directly (Recommended) |
| GUI Builder | gui | Visual query builder (Coming soon) |
Recommended: Use Raw SQL for full control
Query Editorโ
Purpose: Write the SQL statement to execute.
Features:
- Syntax highlighting (PostgreSQL dialect)
- Auto-completion
- Line numbers
- Code folding
- Format/Beautify button
Editor Options:
{
"queryType": "query",
"query": "SELECT * FROM users WHERE active = true;"
}
Query Parametersโ
Overviewโ
Parameters allow you to create dynamic queries that accept input values at execution time.
Parameter Structureโ
| Field | Type | Required | Options | Description |
|---|---|---|---|---|
| Key | String |