Skip to content

PostgreSQL Query

The PostgreSQL Query module allows executing SQL queries on PostgreSQL databases. It supports dynamic variables in the query, flexible SSL configuration (including true, require, prefer modes and custom SSL objects), and robust credential validation. Results include metadata with connection information and the executed query. It is ideal for reading and writing data in PostgreSQL within automated workflows.

ParameterTypeRequiredDescription
credentials_idcredentialsYesPostgreSQL connection credentials
querycodeYesSQL query to execute (supports {{variable}} variables)

The credential must contain the fields:

  • host: PostgreSQL server address (required)
  • user: Database user (required)
  • password: User password
  • database: Database name (required)
  • port: Connection port (default: 5432)
  • ssl: Optional SSL configuration (true, "require", "prefer", or a custom SSL object)
{
"nextModule": "siguiente_modulo",
"data": [
{ "id": 1, "nombre": "Ejemplo", "email": "test@test.com" }
],
"_meta_": {
"rowCount": 2,
"queryExecuted": "SELECT * FROM usuarios",
"connectionInfo": {
"host": "localhost",
"database": "midb",
"ssl": false
}
}
}
{
"credentials_id": "cred_postgres_01",
"query": "SELECT * FROM productos WHERE activo = true LIMIT 100"
}
  • Supports dynamic variables {{variable}} in the SQL query
  • SSL configuration is automatically detected from the credentials
  • If ssl is true or "true", SSL is enabled with rejectUnauthorized: false (common for cloud providers)
  • If ssl is "require", SSL is enabled with certificate validation
  • The connection is always closed in the finally block
  • Required fields (host, user, database) are validated before attempting the connection
  • In case of error, the PostgreSQL error code and executed query are included
  • sqlQueryPostgresSSL (PostgreSQL queries with SSL certificates)
  • sqlQuery (MySQL queries)
  • sqlQueryMSSQL (SQL Server queries)
  • sqlQueryOracle (Oracle queries)