PostgreSQL

PostgreSQL is a widely used open-source relational database system known for reliability, extensibility, and standards compliance. It stores structured data in tables and supports SQL for querying, transactions, and schema management.

With this integration, you can:

  • Query data: Run SELECT statements to retrieve rows from a database
  • Insert, update, and delete data: Write, modify, and remove rows in a table
  • Execute raw SQL: Run arbitrary SQL statements directly against the database
  • Introspect schemas: Retrieve table structures, columns, primary/foreign keys, and indexes

In Sim, the PostgreSQL integration allows your agents to connect to a PostgreSQL database and query, insert, update, delete, and execute raw SQL against it, as well as introspect the database schema to discover tables, columns, and relationships. This gives your agents the ability to read and write structured data as part of a workflow, and to understand a database's structure before generating or running queries against it.

Usage Instructions

Integrate PostgreSQL into the workflow. Can query, insert, update, delete, and execute raw SQL.

Actions

postgresql_query

Execute a SELECT query on PostgreSQL database

Input

ParameterTypeRequiredDescription
hoststringYesPostgreSQL server hostname or IP address
portnumberYesPostgreSQL server port (default: 5432)
databasestringYesDatabase name to connect to
usernamestringYesDatabase username
passwordstringYesDatabase password
sslstringNoSSL connection mode (disabled, required, preferred)
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

Input

ParameterTypeRequiredDescription
hoststringYesPostgreSQL server hostname or IP address
portnumberYesPostgreSQL server port (default: 5432)
databasestringYesDatabase name to connect to
usernamestringYesDatabase username
passwordstringYesDatabase password
sslstringNoSSL connection mode (disabled, required, preferred)
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

Input

ParameterTypeRequiredDescription
hoststringYesPostgreSQL server hostname or IP address
portnumberYesPostgreSQL server port (default: 5432)
databasestringYesDatabase name to connect to
usernamestringYesDatabase username
passwordstringYesDatabase password
sslstringNoSSL connection mode (disabled, required, preferred)
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

Input

ParameterTypeRequiredDescription
hoststringYesPostgreSQL server hostname or IP address
portnumberYesPostgreSQL server port (default: 5432)
databasestringYesDatabase name to connect to
usernamestringYesDatabase username
passwordstringYesDatabase password
sslstringNoSSL connection mode (disabled, required, preferred)
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

Input

ParameterTypeRequiredDescription
hoststringYesPostgreSQL server hostname or IP address
portnumberYesPostgreSQL server port (default: 5432)
databasestringYesDatabase name to connect to
usernamestringYesDatabase username
passwordstringYesDatabase password
sslstringNoSSL connection mode (disabled, required, preferred)
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

Input

ParameterTypeRequiredDescription
hoststringYesPostgreSQL server hostname or IP address
portnumberYesPostgreSQL server port (default: 5432)
databasestringYesDatabase name to connect to
usernamestringYesDatabase username
passwordstringYesDatabase password
sslstringNoSSL connection mode (disabled, required, preferred)
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

On this page