psql2csv
« Back to VersTracker
Description:
Run a query in psql and output the result as CSV
Type: Formula  |  Tracked Since: Dec 28, 2025
Links: Homepage  |  formulae.brew.sh
Category: Databases
Tags: postgresql csv export cli database
Install: brew install psql2csv
About:
psql2csv is a command-line utility that executes a PostgreSQL query and formats the output directly as CSV. It simplifies the process of exporting data by eliminating the need for manual formatting or intermediate steps. This tool is ideal for developers and data engineers needing quick, scriptable data dumps for analysis or migration.
Key Features:
  • Direct CSV output from SQL queries
  • Uses standard psql environment variables for connection
  • Zero-configuration command-line interface
  • Piped output support for streaming data
Use Cases:
  • Exporting query results for data analysis in spreadsheets
  • Automating database backups or data migration scripts
  • Generating CSV reports for external reporting tools
Alternatives:
  • psql \copy – Native PostgreSQL command requiring verbose syntax and file path management
  • csvkit (csvsql) – More comprehensive suite but heavier dependency for simple CSV exports
Version History
Detected Version Rev Change Commit