I can export my data using
gcloud sql export csv .... --query='SELECT * FROM mytable'
My SELECT sql command is long and I'd like to pass it to gcloud in a file. I couldn't find anything in the docs about that. Is this possible to pass a file?
https://cloud.google.com/sql/docs/mysql/import-export/import-export-csv#gcloud
using options shown here: https://unix.stackexchange.com/questions/393351/pass-contents-of-file-as-argument-to-bash-script
This worked:
--query="$(<myFile.sql)"
The answer @Piotr W. provided was just missing quotations.
Worth noting this method allowed me to put my SELECT statement with line breaks in a file vs providing the SELECT statement inline that could not have line breaks, making it hard to read and update.