Created
April 22, 2019 07:34
-
-
Save sousk/dfb60957c8d4da7c828916cd4a6cd104 to your computer and use it in GitHub Desktop.
dump SQL select into CSV with gcolud spanner command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gcloud spanner databases execute-sql dbname --instance=instance-name --project=project-name --format=json --sql=(cat query.sql | ruby -e 'STDIN.select{|l| ! l.match /^[\s\t]*--/ }.each{|l| print l.chomp, " "}') | jq -r '.rows[] | map(.[0]) | map("\"" + . + "\"") | join(",")' > result.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment