Skip to content
Proud to collaborate with Microsoft for Startups

neon.queries.run ​

Execute a SQL statement over psycopg3 against a Neon branch

Executes a single SQL statement against a Neon branch over the Postgres wire protocol (psycopg3). This atomic does NOT use the Neon REST API for query execution — it connects directly with the supplied connection_uri.

The driver (psycopg[binary]) is an optional dependency of base-library, installed only in environments that run this atomic::

pip install ltinteg-workflow-base-library[neon-query]

Inputs:

  • connection_uri: str — full postgres DSN with embedded credentials (required). Treated as a secret: never logged. Scheme MUST be postgres:// or postgresql:// — any other scheme is a non-retryable error.
  • sql: str — the SQL statement to execute (required).
  • params: list — positional query parameters; passed parameterised, never string-formatted (optional).
  • fetch_results: bool — whether to fetch rows (optional, default: True).
  • timeout_seconds: int — connect timeout, capped at 120 (optional, default: 30).

Outputs (terminal state_data):

  • rows: list — list of row dicts (empty if DML/DDL or fetch_results is False)
  • row_count: int — cursor rowcount
  • status_message: str — e.g. "SELECT 5", "INSERT 0 1"

Credential handling: authentication is entirely in connection_uri; this atomic never calls context.get_plugin("neon"). The URI is supplied by the orchestration workflow (C-06) that first calls A-20 to obtain it.

Notes:

  • autocommit=True is required: Neon serverless suspends on idle and re-opening a transaction across suspend/resume is unreliable.

Overview ​

PropertyValue
Workflow typeAtomic
LibraryBase
Version1.0

Input Schema ​

FieldTypeRequiredDefaultDescription
connection_uristringYes—Full postgres DSN with embedded credentials (secret)
sqlstringYes—SQL statement to execute
paramslistNo—Positional query parameters (parameterised)
fetch_resultsbooleanNo—Whether to fetch rows (default: True)
timeout_secondsintegerNo—Connect timeout seconds (default: 30, cap 120)

Output Schema ​

FieldTypeRequiredDefaultDescription
rowslistNo—List of row dicts (empty for DML/DDL)
row_countintegerNo——
status_messagestringNo—e.g. 'SELECT 5', 'INSERT 0 1'
connection_uristringNo——
sqlstringNo——
paramslistNo——
fetch_resultsbooleanNo——
timeout_secondsintegerNo——
failure_reasonstringNo——
failure_typestringNo——
failed_actionstringNo——
failed_at_statestringNo——
failed_stepstringNo——
failed_layerstringNo——
errorstringNo——
error_typestringNo——

States ​

StateInitialTerminalSuccessAuto-advanceDescription
pendingYesNo—execute—
completedNoYesYes——
failedNoYesNo——

State Diagram ​

Transitions ​

FromActionToDescription
pendingexecutecompleted—
* (any state)failfailed—

API Usage ​

bash
POST /api/workflows/start
Content-Type: application/json

{
  "workflow_type": "neon.queries.run",
  "initial_data": {
    "connection_uri": "value",
    "sql": "value"
  }
}