Create Client & AccessPolicy for your API agent - in our case curl
PUT /Accept:text/yamlContent-Type:text/yaml- resourceType:Clientid:bulk-clientsecret:secretgrant_types: ['basic']- resourceType:AccessPolicyid:bulk-clientengine:allowlink: - {id:'bulk-client',resourceType:'Client'}
Generate some number of patients using SQL - in DB Console:
INSERT INTO patient (id,txid, status, resource) SELECT g.id, g.id, 'created', '{"name": [{"family": "John"}]}'FROMgenerate_series(1, 100000) AS g (id);--SELECTcount(*) FROM Patient;
Now we can test bulk export using $dump operation with curl program:
curl-ubulk-client:secret/Patient/\$dump>/tmp/pt.ndjson> % Total % Received % Xferd Average Speed Time Time Time Current> Dload Upload Total Spent Left Speed> 100 12.0M 0 12.0M 0 0 9527k 0 --:--:-- 0:00:01 --:--:-- 9523kless/tmp/pt.ndjson
We got 100K patients in less than a second!
Do not forget to clean up the database:
TRUNCATE Patient;
Load data into BigQuery
# load tsv datacurl-v-XPOST-ubulk-client:secret-H'content-type:application/json' \https://<YOURBOX>/\$dump-sql \-d'{"query": "select id, ts, resource#>>'"'"'{module}'"'"' from entity"}' \>data.tsv# create datasetbqmktestbqls# load datastbqload--source_format=CSV \--field_delimiter=tab \test.entities./data.tsvres,ts,mod# list idsbqquery'select id from test.entities'# remove datasetbqrm-rtest