sql2csv-cmd

command module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

README

sql2csv-cmd

GoDoc Quality Test Release License

cli application for extracting data as csv from a PostgreSQL database using sql

Usage

Usage of sql2csv-cmd:
  -c string
    	connection string for the database: postgres://user:pass@host:port/dbname
  -d string
    	hostname for database as defined in .pgpass
  -f string
    	file containing query to run eg. query.sql
  -o string
    	output filename eg. result.csv
  -q string
    	query to run
  -t int
    	query timeout in seconds
  -v	verbose mode

Example

sql2csv-cmd -d db.example.com -q "SELECT * FROM public.users" -o users.csv
sql2csv-cmd -d db.example.com -f query.sql -o query.csv

Installation

Linux amd64
# install
curl -L https://github.com/frederikhs/sql2csv-cmd/releases/latest/download/sql2csv-cmd_Linux_x86_64.tar.gz -o sql2csv-cmd.tar.gz
tar -xvf sql2csv-cmd.tar.gz
sudo mv sql2csv-cmd /usr/local/bin/sql2csv-cmd

# clean up
rm sql2csv-cmd.tar.gz

.pgpass

sql2csv-cmd uses the .pgpass file that resides in the $HOME directory of the user running the program.


Example of a connection configuration in the .pgpass file

<HOST>:<PORT>:<DATABASE>:<USERNAME>:<PASSWORD>

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL