Vijay Kumar Sharma
Vijay Kumar Sharma

Reputation: 397

how to upload the .sql file onto big query using bq command line

when using bq command tool, can I directly upload the .sql file. because it shows that the specified file is missing when executing the code to find the command

I have tried this one approach:

while read -r q; do bq query --project_id=my-proj --dataset_id=sample_db --nouse_legacy_sql "$q" done < <(grep '^INSERT' sample_db_export.sql)

These PowerShell commands also read lines beginning with INSERT and run the queries using the bq command-line tool.

Select-String -pattern '^INSERT' ./sample_db_export.sql | %{ bq query --project=my-proj --dataset_id=sample_db --nouse_legacy_sql $_.Line }

Upvotes: 0

Views: 2000

Answers (1)

Elliott Brossard
Elliott Brossard

Reputation: 33705

It's hard to tell what you are asking. If you have the query in a file called sample_db_export.sql, just pipe it as input to bq query. For example,

bq query --use_legacy_sql=false < sample_db_export.sql

Upvotes: 2

Related Questions