Skip to content
DocsOpen Hub
Node reference

Database node

On this page

A Database node executes SQL against its configured database and makes the result available to later workflow steps. Choose the environment binding and query contract before adding it to a live path.

Configure a query#

  1. Create or connect the database under Workflows → Databases.
  2. Add a Database node and give it a meaningful name such as ListTasks.
  3. Select its sandbox and production database bindings.
  4. Enter SQL for the selected database engine.
  5. Connect it after input validation and authorization.

For a SQLite table created by the database API guide:

sql
SELECT id, title, status
FROM Tasks
ORDER BY id DESC
LIMIT 20;

Pass values as data#

Cloudgate binds selectors in saved SQL as values. A selector cannot supply a table name or an executable SQL fragment within a statement. Use fixed table and column names and filter on validated input.

For explicit parameter input, use the supported parameterized script form described in SQL and parameters. Do not build SQL by concatenating text from a request body.

Inspect the result#

Run the query against sandbox fixture data and inspect the actual output. Reference ${ListTasks} directly in a downstream Function if you need to normalize the result for a client.

SELECT results with rows are serialized as a JSON array. An empty SELECT can produce the text No records found rather than an empty array. Normalize that case in a response Function if your client expects a consistent collection. The database API guide shows the complete pattern.

Treat mutations separately#

INSERT, UPDATE, and DELETE statements change the selected database immediately when the node runs. Verify the binding before testing. Scope writes to the intended record and authenticated owner, and test affected-row behavior for a missing record.

Node or workflow rollback does not undo data already written. Use backups and a deliberate migration plan for schema changes. If a SQL operation fails, inspect that node's error before retrying the entire workflow; earlier external effects may already have completed.

Need to investigate a problem? Start with troubleshooting