PostgreSQL

Frends.PostgreSQL.ExecuteQuery / 2.0.0

Summary

Runs SQL against PostgreSQL and returns the result, with parameters passed separately from the statement text.

Typical use — reading from and writing to PostgreSQL; parameterising rather than concatenating is also what keeps injection out of the query

Details

Frends version
5.5 and newer
Agent
Crossplatform
Target framework
net6.0

Input-class for ExecuteQuery-task.

Name Type Default Example Description
Query String SELECT * FROM Users SELECT * FROM Users

Query. Note: Normal query requires double quotes around Column and 2 single quotes around Value.

Parameters Parameter[] [{ Name = "Name", Value = "Erik" }, { Name = "Email", Value = "erik.example@foobar.com" }]

Query parameters.

ConnectionStringSecret String Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;

Connection string.

ExecuteType ExecuteTypes Auto ExecuteTypes.Auto

Specifies how a command string is interpreted. Auto: Automatically detects if the query returns data (SELECT or RETURNING clause) and uses ExecuteReader, otherwise uses NonQuery. ExecuteReader: Use this to execute queries that return a result set (SELECT or INSERT/UPDATE/DELETE with RETURNING clause). NonQuery: Use this to execute commands that don't return a result set (INSERT, UPDATE, DELETE without RETURNING). Returns the number of affected rows.

Possible values:

  • Auto: Auto-detect based on query structure. Uses ExecuteReader for queries that return data (SELECT or queries with RETURNING clause). Uses NonQuery for INSERT, UPDATE, DELETE statements without RETURNING clause.

  • NonQuery: Execute the query without expecting any result set. Use for INSERT, UPDATE, DELETE statements without RETURNING clause. Returns the number of rows affected.

  • ExecuteReader: Execute the query and return the result set. Use for SELECT queries or INSERT/UPDATE/DELETE with RETURNING clause. Returns the data rows.

An unhandled error has occurred. Reload 🗙