Skip to main content
MindStudio
Pricing
Blog About
My Workspace
Databases

Query App Database

The Query App Database block runs a SQL statement against a SQLite database managed by your MindStudio app.

Execute SQL queries against your app's database

The Query App Database block runs a SQL statement against a SQLite database managed by your MindStudio app. You provide a database ID to identify which database to target and a SQL string containing the query to execute. An optional parameterize setting controls how variables in the query are handled, and you can specify a destination variable to store the results for use in later steps.

The block returns an object with two fields: rows, which is an array of records returned by SELECT queries, and changes, which is an integer representing the number of rows affected by INSERT, UPDATE, or DELETE operations. For read queries you get structured JSON data back; for write operations you get a count of affected rows.

This block fits into workflows that need to persist, retrieve, or modify structured data as part of a larger AI-driven process. Common patterns include storing user inputs or AI-generated content into a database, looking up records to feed into a prompt, or updating entries based on conditions evaluated elsewhere in the workflow.

What you can build

Real-world workflows powered by the Query App Database block.

Store User Form Inputs

Insert data collected from a user interaction into a database table for later retrieval or reporting.

Retrieve Records for AI Prompts

Run a SELECT query to fetch relevant records and pass them as context into an AI generation step.

Log AI-Generated Outputs

Write AI-generated text or structured results into a database table to maintain a persistent history.

Update Records Conditionally

Execute an UPDATE statement to modify existing rows based on conditions evaluated in a prior workflow step.

Build Dynamic Reporting

Query aggregated or filtered data from the database and surface the results in a dashboard or summary response.

Delete Stale or Expired Entries

Run a DELETE query to remove outdated records as part of a scheduled or triggered cleanup workflow.

Ready to add Query App Database to your workflow?

Get Started Free

Common questions about Query App Database

What are the required parameters for this block?

The block requires a databaseId, which identifies the app-managed SQLite database to target, and a sql field containing the SQL statement to execute. The parameterize and destinationVar fields are optional.

What does the block return?

The block returns an object with two fields: rows, an array of records returned by SELECT queries, and changes, an integer indicating the number of rows affected by INSERT, UPDATE, or DELETE statements.

How does parameterization work, and when should I disable it?

By default, parameterize is enabled, which means variables in your SQL are automatically extracted and passed as safe parameterized values to prevent SQL injection. Set parameterize to false only when another step has already generated a complete or partial SQL string that needs to be interpolated directly, such as a precomputed bulk INSERT with a VALUES list. When parameterize is false, you are responsible for sanitizing the input.

What kinds of workflows commonly use this block?

This block is used in workflows that need to read from or write to a structured database — for example, storing user inputs, retrieving records to pass into AI prompts, logging outputs, or updating entries based on conditions evaluated in earlier steps.

What database type does this block work with?

The block executes SQL against a SQLite database managed by the MindStudio app, identified by the databaseId parameter.

Add Query App Database to your workflow

Build powerful AI workflows with drag-and-drop blocks. No coding required.