PostgreSQL

Frends.PostgreSQL.ExecuteQueryToFile / 1.0.0

Summary

Executes a PostgreSQL query and writes the results directly into a CSV or JSON file.

Remarks

The result set is streamed from the database to the file row by row, so the amount of data
is not limited by memory and nothing is returned to the Process except a summary.
The data is first written to a temporary file next to the output file and moved into place
when the query has completed, so a failed run never leaves a partial output file behind.
Binary columns are written as Base64 text, and JSON/JSONB columns are written as JSON
into JSON output and as text into CSV output.

Details

Frends version
5.7 and newer
Agent
Crossplatform
Target framework
net8.0

Essential parameters.

Name Type Default Example Description
Query String SELECT * FROM users SELECT * FROM users WHERE name = @Name

Query to execute. Use parameter placeholders (e.g. @Name) together with the Parameters property instead of concatenating values into the query.

Parameters Parameter[] – [ { Name = "Name", Value = "Erik" } ]

Query parameters.

OutputFilePath String – C:\output\users.csv

Full path of the file the query result is written to.

ActionOnExistingFile ActionOnExistingFile Overwrite ActionOnExistingFile.Overwrite

What to do if the output file already exists.

Possible values:

  • Overwrite: Replace the existing file.

  • Throw: Fail without running the query.

An unhandled error has occurred. Reload 🗙