Skip to content

Integrations

PostgreSQL

Connect to PostgreSQL database

Use PostgreSQL to query and modify rows, execute SQL, and inspect tables, columns, keys, and indexes. Schema inspection lets a workflow discover the database structure before generating a query.

Connection setup

In Integrations, add a connection with the host, port, database, username, password, and transport-security settings. Sim proves the connection with SELECT 1 before saving it encrypted, then reads it on the server for each run; the block, the workflow, and agents never see the password. Reconnect the connection from Integrations when its credentials change. The runtime must be able to reach the database host.

  • Preferred encrypts when the server offers TLS and otherwise connects without it. An attacker on the network can force that fallback, so choose Required when the server supports TLS.
  • Required always encrypts but does not verify the server certificate, like libpq's sslmode=require.
  • Disabled never encrypts. Use it only on a network whose confidentiality you control.

Workflows built before saved connections keep their inline connection fields and run unchanged.

Use the block

Query or modify PostgreSQL rows, execute SQL, and inspect tables, columns, keys, and indexes.

Actions

PostgreSQL Query

Execute a SELECT query on PostgreSQL database

Inputs and outputs

Input

ParameterTypeRequiredDescription
querystringYesSQL SELECT query to execute

Output

ParameterTypeDescription
messagestringOperation status message
rowsarrayArray of rows returned from the query
rowCountnumberNumber of rows returned

PostgreSQL Insert

Insert data into PostgreSQL database

Inputs and outputs

Input

ParameterTypeRequiredDescription
tablestringYesTable name to insert data into
dataobjectYesData object to insert (key-value pairs)

Output

ParameterTypeDescription
messagestringOperation status message
rowsarrayInserted data (if RETURNING clause used)
rowCountnumberNumber of rows inserted

PostgreSQL Update

Update data in PostgreSQL database

Inputs and outputs

Input

ParameterTypeRequiredDescription
tablestringYesTable name to update data in
dataobjectYesData object with fields to update (key-value pairs)
wherestringYesWHERE clause condition (without WHERE keyword)

Output

ParameterTypeDescription
messagestringOperation status message
rowsarrayUpdated data (if RETURNING clause used)
rowCountnumberNumber of rows updated

PostgreSQL Delete

Delete data from PostgreSQL database

Inputs and outputs

Input

ParameterTypeRequiredDescription
tablestringYesTable name to delete data from
wherestringYesWHERE clause condition (without WHERE keyword)

Output

ParameterTypeDescription
messagestringOperation status message
rowsarrayDeleted data (if RETURNING clause used)
rowCountnumberNumber of rows deleted

PostgreSQL Execute

Execute raw SQL query on PostgreSQL database

Inputs and outputs

Input

ParameterTypeRequiredDescription
querystringYesRaw SQL query to execute

Output

ParameterTypeDescription
messagestringOperation status message
rowsarrayArray of rows returned from the query
rowCountnumberNumber of rows affected

PostgreSQL Introspect

Introspect PostgreSQL database schema to retrieve table structures, columns, and relationships

Inputs and outputs

Input

ParameterTypeRequiredDescription
schemastringNoSchema to introspect (default: public)

Output

ParameterTypeDescription
messagestringOperation status message
tablesarrayArray of table schemas with columns, keys, and indexes
↳ namestringTable name
↳ schemastringSchema name (e.g., public)
↳ columnsarrayTable columns
↳ namestringColumn name
↳ typestringData type (e.g., integer, varchar, timestamp)
↳ nullablebooleanWhether the column allows NULL values
↳ defaultstringDefault value expression
↳ isPrimaryKeybooleanWhether the column is part of the primary key
↳ isForeignKeybooleanWhether the column is a foreign key
↳ referencesobjectForeign key reference information
↳ tablestringReferenced table name
↳ columnstringReferenced column name
↳ primaryKeyarrayPrimary key column names
↳ foreignKeysarrayForeign key constraints
↳ columnstringLocal column name
↳ referencesTablestringReferenced table name
↳ referencesColumnstringReferenced column name
↳ indexesarrayTable indexes
↳ namestringIndex name
↳ columnsarrayColumns included in the index
↳ uniquebooleanWhether the index enforces uniqueness
schemasarrayList of available schemas in the database
Was this helpful?
Suggest an edit