Skip to content

Instantly share code, notes, and snippets.

@yaniv-aknin
Created March 14, 2022 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaniv-aknin/22fee0e09ee14dd2d53ea44cbf670cd0 to your computer and use it in GitHub Desktop.
Save yaniv-aknin/22fee0e09ee14dd2d53ea44cbf670cd0 to your computer and use it in GitHub Desktop.
from google.cloud import bigquery
c = bigquery.Client()
job_config = bigquery.LoadJobConfig(
source_format=bigquery.SourceFormat.NEWLINE_DELIMITED_JSON,
write_disposition='WRITE_APPEND')
job = c.load_table_from_json([{'id': '7', 'value': 'qux'}], 'test_dataset.test_table', job_config=job_config)
print(job.result())
bq mk test_dataset.test_table id:string,value:string
bq load --source_format=NEWLINE_DELIMITED_JSON test_dataset.test_table test.jsonl
python3 load.py
{"id": "5", "value": "foo"}
{"id": "6", "value": "bar"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment