Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Format output of query

I am running SnowQL queries like so –

snowsql -u user -w cluster -d db -s public -a "account" -r admin -q "SELECT bucket FROM buckets GROUP BY bucket" | while read bucket_name_var ; 
do
if [ ! -z "$bucket_name_var" ]
then
fi
done

This is the output it produces –

* SnowSQL * v1.2.20
Type SQL statements or !help
+-------------+
| BUCKET
|-------------|
| 960         |
+-------------+
1 Row(s) produced. Time Elapsed: 0.927s
Goodbye!

How do I get this output instead –

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

960

I want this output so that bucket_name_var variable will only have output values (e.g. 960) that can be looped because right now everything from the version of Snowflake to goodbye is being looped on.

>Solution :

Add this to your snowsql command to get raw output:

-o friendly=false -o header=false -o timing=false -o output_format=plain

Reference: https://snowflakecommunity.force.com/s/article/SnowSQL-display-raw-result-of-a-query

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading