Monitoring, Management & Location Tracking

 View Only
last person joined: one year ago 

Articles relating to existing and legacy HPE Aruba Networking products and solutions including AirWave, Meridian Apps, ALE, Central / HPE Aruba Networking Central, and UXI / HPE Aruba Networking User Experience Insight

How do I output a database report in CSV format? 

Jun 06, 2014 05:48 PM

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]

Statistics
0 Favorited
0 Views
0 Files
0 Shares
0 Downloads

Related Entries and Links

No Related Resource entered.