Export a query to a file
pg_export_queryRun read-only PostgreSQL queries and export large results to CSV, JSON, or JSON Lines files instead of returning rows, with only the file path, row count, and size reported.
Instructions
Run a read-only query and save the result to a local file (CSV, JSON or JSON Lines) instead of sending the rows to the conversation. Use it for results too big to read: the answer holds only the path, the row count and the size.
The query goes through the same safety checks as pg_query (one statement, read only,
protected columns refused, credential-like columns redacted); use params ($1, $2, ...)
for values. filename is a plain file name, written to the connection's export folder
(default ~/pgharbor-exports). Up to max_rows rows, never more than 100,000; the file is
not overwritten unless overwrite=true. Exports can be turned off per connection.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"sql": "<sql>",
"filename": "<filename>"
},
"name": "pg_export_query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | ||
| format | No | csv | |
| params | No | ||
| filename | Yes | ||
| max_rows | No | ||
| overwrite | No | ||
| connection | No |