mirror of
https://github.com/cheat/cheat.git
synced 2024-12-18 10:45:05 +01:00
improved command to export query result to csv file
This commit is contained in:
parent
2aa37432cb
commit
9c53e2ba10
@ -16,8 +16,9 @@ psql -U postgres -d dbName -c 'select * from tableName;' -o fileName
|
||||
# Execute query and get tabular html output:
|
||||
psql -U postgres -d dbName -H -c 'select * from tableName;'
|
||||
|
||||
# Execute query and save resulting rows to csv file:
|
||||
psql -U postgres -d dbName -t -A -P fieldsep=',' -c 'select * from tableName;' -o fileName.csv
|
||||
# Execute query and save resulting rows to csv file
|
||||
# (if column names in the first row are not needed, remove the word 'header'):
|
||||
psql -U postgres -d dbName -c 'copy (select * from tableName) to stdout with csv header;' -o fileName.csv
|
||||
|
||||
# Read commands from file:
|
||||
psql -f fileName
|
||||
|
Loading…
Reference in New Issue
Block a user