Created
March 14, 2022 22:09
-
-
Save yaniv-aknin/22fee0e09ee14dd2d53ea44cbf670cd0 to your computer and use it in GitHub Desktop.
This file contains 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
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()) |
This file contains 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
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 |
This file contains 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
{"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