Export to CSV file
Run a SELECT or a stored procedure with ? parameters and write its rows to a CSV file without loading them into memory.
Command in the Database toolkit · id ooa.database/export_to_file · 13 inputs (1 required), 2 outputs
Inputs
| Input | Type | Required | Default | What it is |
|---|---|---|---|---|
| SQL statement | String | No | SELECT statement with ? placeholders (or use procedure). | |
| Path | File | Yes | CSV file to create. | |
| Parameters | List | No | Values for the ? placeholders, in order. | |
| Delimiter | String | No | , | Field separator, e.g. , or ; or tab. |
| First row is the header | Boolean | No | true | Write the column names as the first line. |
| Encoding | String | No | utf-8 | Text encoding of the file. |
| Session | String | No | db | Session name. |
| Query timeout (seconds) | Number | No | 0 | Cancel the statement after this many seconds; 0 waits as long as the step allows. |
| Overwrite | Boolean | No | true | Replace an existing file; when false an existing file stops the step. |
| Procedure | String | No | Stored procedure whose first result set is written, used instead of sql; parameters are its input values in order. | |
| Maximum rows | Number | No | 0 | Stop after writing this many rows; 0 writes them all. |
| Append | Boolean | No | false | G2 (AA parity): add the rows to the end of the file when it is there (without a second header line). |
| Skip when no rows | Boolean | No | false | G2 (AA parity): make no file when the query gives no rows (path is then empty). |
Outputs
| Output | Type | What it is |
|---|---|---|
| path | File | Written file. |
| row_count | Number | Rows written. |