I am new to google spanner and I have run a query and found about 50k rows of data. I want to export that resultset to my local machine like .csv or into a google sheet. Previously I have used TOAD where I have an export button, but here I do not see any of those options. Any suggestions please.
相关问题
- Why do Dataflow steps not start?
- __call__() missing 1 required positional argument:
- Cannot upload large file to Google Cloud Storage
- How to set query parameters dialogflow php sdk
- Google Data Studio connect to cloud datastore
相关文章
- How do I create a persistent volume claim with Rea
- GKE does not scale to/from 0 when autoscaling enab
- Can't push image to google container registry
- Your application has authenticated using end user
- boost serialization and register_type
-
Google App Engine Error:
INVALID_ARGUMENT - How to create a namespace if it doesn't exists
- BASH: Is “export” needed, when setting a variable
The
gcloud spanner databases execute-sql
command allows you to run SQL statements on the command line and redirect output to a file. The--format=csv
global argument should output in CSV.https://cloud.google.com/spanner/docs/gcloud-spanner https://cloud.google.com/sdk/gcloud/reference/
Unfortunately,
gcloud spanner databases execute-sql
is not quite compatible with--format=csv
because of the way the data is laid out under the hood (an array instead of a map). It's much less pretty, but this works:This dumps the query in json form to data.json, then writes the column names to the CSV, followed by a line feed, and finally the row contents. As a bonus, jq is installed by default on cloudshell, so this shouldn't carry any extra dependencies there.
You could use a number of standard database tools with Google Cloud Spanner using a JDBC driver.
Have a look at this article: https://www.googlecloudspanner.com/2017/10/using-standard-database-tools-with.html
Toad is not included as an example, and I don't know if Toad supports dynamic loading of JDBC drivers and connecting to any generic JDBC database. If not, you could try one of the other tools listed in the article. Most of them would also include an export function.