Monitoring, Management & Location Tracking

How do I output a database report in CSV format?

Aruba Employee

From the AMP command line interface you can generate custom reports by specifying the correct database query. 

In 6.2 and newer, use the dbcsv alias:

# dbcsv "select id, name from ap"

In older versions:


To have that report output in comma separated value (CSV) format, you just need to add a few formatting options when you run the query. 

The basic format of your command will look something like this:

echo "[QUERY]" | psql -Uairwave airwave [FORMATTING_OPTIONS] 
--output [CSV_OUTPUT_FILE]


The following example generates a CSV file containing a list of all APs with their associated Group and Folder...


FORMATTED FOR EASIER READING (also uses long versions of psql options):

echo
"select ap.name, ap_group.name, ap_folder.name
from ap, ap_group, ap_folder
where ap.ap_folder_id=ap_folder.id and ap.ap_group_id=ap_group.id" |
psql -Uairwave airwave --no-align --field-separator , --tuples-only
--output [CSV_OUTPUT_FILE]

[Example CSV_OUTPUT_FILE: /tmp/db_output.csv]


FORMATTED FOR EASY COPY AND PASTE (uses abbreviated versions of psql options):

echo "select ap.name, ap_group.name, ap_folder.name from ap, ap_group, ap_folder where ap.ap_folder_id=ap_folder.id and ap.ap_group_id=ap_group.id" | psql -Uairwave airwave -A -F , -t -o [CSV_OUTPUT_FILE]

Version history
Revision #:
1 of 1
Last update:
‎06-06-2014 02:48 PM
Updated by:
 
Labels (1)
Contributors
Search Airheads
cancel
Showing results for 
Search instead for 
Did you mean: