Google BigQuery Flow
This flow explains simple usage to query and store data in BigQuery, using node-red-contrib-bigquery
The following table schema is used for this sample.
[
{ "name": "id", "type": "integer", "mode": "nullable" },
{ "name": "username", "type": "string", "mode": "nullable" },
{ "name": "name", "type": "string", "mode": "nullable" },
{ "name": "email", "type": "string", "mode": "nullable" }
]
You can create the table via bq
command.
$ bq mk --schema schema.json -t nodered.users
To execute this flow, you need to download a private key from Google Cloud Platform.
Sample image
[{"id":"4e4dd26c.2f0fec","type":"bigquery query","z":"d798bf30.6a942","bigquery":"","query":"SELECT * FROM nodered.users;","name":"query","x":370,"y":220,"wires":[["e3018480.5ff4f8"]]},{"id":"cc2a3c34.d11c5","type":"inject","z":"d798bf30.6a942","name":"start","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":109.5,"y":118,"wires":[["4e4dd26c.2f0fec"]]},{"id":"e3018480.5ff4f8","type":"debug","z":"d798bf30.6a942","name":"print","active":true,"console":"false","complete":"payload","x":650,"y":160,"wires":[]},{"id":"b27c1107.88232","type":"inject","z":"d798bf30.6a942","name":"start","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":110,"y":280,"wires":[["ddc18dc8.83527"]]},{"id":"ddc18dc8.83527","type":"function","z":"d798bf30.6a942","name":"sample data","func":"msg.payload = '[{ \"id\": 1, \"username\": \"user1\", \"name\": \"User1\", \"email\": \"[email protected]\" }, { \"id\": 2, \"username\": \"user2\", \"name\": \"User2\", \"email\": \"[email protected]\" }, { \"id\": 3, \"username\": \"user3\", \"name\": \"User3\", \"email\": \"[email protected]\" }]';\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":380,"wires":[["a606f050.9ed93"]]},{"id":"a606f050.9ed93","type":"bigquery insert","z":"d798bf30.6a942","bigquery":"","dataset":"nodered","table":"users","name":"store","x":650,"y":320,"wires":[]},{"id":"9fb399da.2d03b","type":"comment","z":"d798bf30.6a942","name":"query","info":"","x":70,"y":80,"wires":[]},{"id":"714d6a5c.4fd74c","type":"comment","z":"d798bf30.6a942","name":"insert","info":"","x":70,"y":240,"wires":[]}]