|
1 | | -<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/> |
| 1 | +Samples for the [BigQuery API Node.js Client][client] have moved to |
| 2 | +[github.com/googleapis/nodejs-bigquery/tree/master/samples/][samples]. |
2 | 3 |
|
3 | | -# Google BigQuery Node.js Samples |
4 | | - |
5 | | -[]() |
6 | | - |
7 | | -[BigQuery](https://cloud.google.com/bigquery/docs) is Google's fully managed, petabyte scale, low cost analytics data warehouse. BigQuery is NoOps—there is no infrastructure to manage and you don't need a database administrator—so you can focus on analyzing data to find meaningful insights, use familiar SQL, and take advantage of our pay-as-you-go model. |
8 | | - |
9 | | -## Table of Contents |
10 | | - |
11 | | -* [Setup](#setup) |
12 | | -* [Samples](#samples) |
13 | | - * [Datasets](#datasets) |
14 | | - * [Tables](#tables) |
15 | | - * [Queries](#queries) |
16 | | -* [Running the tests](#running-the-tests) |
17 | | - |
18 | | -## Setup |
19 | | - |
20 | | -1. Read [Prerequisites][prereq] and [How to run a sample][run] first. |
21 | | -1. Install dependencies: |
22 | | - |
23 | | - With **npm**: |
24 | | - |
25 | | - npm install |
26 | | - |
27 | | - With **yarn**: |
28 | | - |
29 | | - yarn install |
30 | | - |
31 | | -[prereq]: ../README.md#prerequisites |
32 | | -[run]: ../README.md#how-to-run-a-sample |
33 | | - |
34 | | -## Samples |
35 | | - |
36 | | -### Datasets |
37 | | - |
38 | | -View the [documentation][datasets_0_docs] or the [source code][datasets_0_code]. |
39 | | - |
40 | | -__Usage:__ `node datasets.js --help` |
41 | | - |
42 | | -``` |
43 | | -Commands: |
44 | | - create <datasetId> Creates a new dataset. |
45 | | - delete <datasetId> Deletes a dataset. |
46 | | - list Lists datasets. |
47 | | -
|
48 | | -Options: |
49 | | - --projectId, -p The Project ID to use. Defaults to the value of the GCLOUD_PROJECT or GOOGLE_CLOUD_PROJECT |
50 | | - environment variables. [string] |
51 | | - --help Show help [boolean] |
52 | | -
|
53 | | -Examples: |
54 | | - node datasets.js create my_dataset Creates a new dataset named "my_dataset". |
55 | | - node datasets.js delete my_dataset Deletes a dataset named "my_dataset". |
56 | | - node datasets.js list Lists all datasets in the project specified by the |
57 | | - GCLOUD_PROJECT or GOOGLE_CLOUD_PROJECT environments variables. |
58 | | - node datasets.js list --projectId=bigquery-public-data Lists all datasets in the "bigquery-public-data" project. |
59 | | -
|
60 | | -For more information, see https://cloud.google.com/bigquery/docs |
61 | | -``` |
62 | | - |
63 | | -[datasets_0_docs]: https://cloud.google.com/bigquery/docs |
64 | | -[datasets_0_code]: datasets.js |
65 | | - |
66 | | -### Tables |
67 | | - |
68 | | -View the [documentation][tables_1_docs] or the [source code][tables_1_code]. |
69 | | - |
70 | | -__Usage:__ `node tables.js --help` |
71 | | - |
72 | | -``` |
73 | | -Commands: |
74 | | - create <datasetId> <tableId> <schema> Creates a new table. |
75 | | - list <datasetId> Lists all tables in a dataset. |
76 | | - delete <datasetId> <tableId> Deletes a table. |
77 | | - copy <srcDatasetId> <srcTableId> <destDatasetId> Makes a copy of a table. |
78 | | - <destTableId> |
79 | | - browse <datasetId> <tableId> Lists rows in a table. |
80 | | - import <datasetId> <tableId> <fileName> Imports data from a local file into a table. |
81 | | - import-gcs <datasetId> <tableId> <bucketName> <fileName> Imports data from a Google Cloud Storage file into a |
82 | | - table. |
83 | | - export <datasetId> <tableId> <bucketName> <fileName> Export a table from BigQuery to Google Cloud Storage. |
84 | | - insert <datasetId> <tableId> <json_or_file> Insert a JSON array (as a string or newline-delimited |
85 | | - file) into a BigQuery table. |
86 | | -
|
87 | | -Options: |
88 | | - --projectId, -p The Project ID to use. Defaults to the value of the GCLOUD_PROJECT or GOOGLE_CLOUD_PROJECT |
89 | | - environment variables. [string] |
90 | | - --help Show help [boolean] |
91 | | -
|
92 | | -Examples: |
93 | | - node tables.js create my_dataset my_table "Name:string, Creates a new table named "my_table" in "my_dataset". |
94 | | - Age:integer, Weight:float, IsMagic:boolean" |
95 | | - node tables.js list my_dataset Lists tables in "my_dataset". |
96 | | - node tables.js browse my_dataset my_table Displays rows from "my_table" in "my_dataset". |
97 | | - node tables.js delete my_dataset my_table Deletes "my_table" from "my_dataset". |
98 | | - node tables.js import my_dataset my_table ./data.csv Imports a local file into a table. |
99 | | - node tables.js import-gcs my_dataset my_table my-bucket Imports a GCS file into a table. |
100 | | - data.csv |
101 | | - node tables.js export my_dataset my_table my-bucket my-file Exports my_dataset:my_table to gcs://my-bucket/my-file |
102 | | - as raw CSV. |
103 | | - node tables.js export my_dataset my_table my-bucket my-file Exports my_dataset:my_table to gcs://my-bucket/my-file |
104 | | - -f JSON --gzip as gzipped JSON. |
105 | | - node tables.js insert my_dataset my_table json_string Inserts the JSON array represented by json_string into |
106 | | - my_dataset:my_table. |
107 | | - node tables.js insert my_dataset my_table json_file Inserts the JSON objects contained in json_file (one per |
108 | | - line) into my_dataset:my_table. |
109 | | - node tables.js copy src_dataset src_table dest_dataset Copies src_dataset:src_table to dest_dataset:dest_table. |
110 | | - dest_table |
111 | | -
|
112 | | -For more information, see https://cloud.google.com/bigquery/docs |
113 | | -``` |
114 | | - |
115 | | -[tables_1_docs]: https://cloud.google.com/bigquery/docs |
116 | | -[tables_1_code]: tables.js |
117 | | - |
118 | | -### Queries |
119 | | - |
120 | | -View the [documentation][queries_2_docs] or the [source code][queries_2_code]. |
121 | | - |
122 | | -__Usage:__ `node queries.js --help` |
123 | | - |
124 | | -``` |
125 | | -Commands: |
126 | | - sync <sqlQuery> Run the specified synchronous query. |
127 | | - async <sqlQuery> Start the specified asynchronous query. |
128 | | - shakespeare Queries a public Shakespeare dataset. |
129 | | -
|
130 | | -Options: |
131 | | - --projectId, -p The Project ID to use. Defaults to the value of the GCLOUD_PROJECT or GOOGLE_CLOUD_PROJECT |
132 | | - environment variables. [string] |
133 | | - --help Show help [boolean] |
134 | | -
|
135 | | -Examples: |
136 | | - node queries.js sync "SELECT * FROM Synchronously queries the natality dataset. |
137 | | - publicdata.samples.natality LIMIT 5;" |
138 | | - node queries.js async "SELECT * FROM Queries the natality dataset as a job. |
139 | | - publicdata.samples.natality LIMIT 5;" |
140 | | - node queries.js shakespeare Queries a public Shakespeare dataset. |
141 | | -
|
142 | | -For more information, see https://cloud.google.com/bigquery/docs |
143 | | -``` |
144 | | - |
145 | | -[queries_2_docs]: https://cloud.google.com/bigquery/docs |
146 | | -[queries_2_code]: queries.js |
147 | | - |
148 | | -## Running the tests |
149 | | - |
150 | | -1. Set the **GCLOUD_PROJECT** and **GOOGLE_APPLICATION_CREDENTIALS** environment variables. |
151 | | - |
152 | | -1. Run the tests: |
153 | | - |
154 | | - With **npm**: |
155 | | - |
156 | | - npm test |
157 | | - |
158 | | - With **yarn**: |
159 | | - |
160 | | - yarn test |
| 4 | +[client]: https://github.com/googleapis/nodejs-bigquery |
| 5 | +[samples]: https://github.com/googleapis/nodejs-bigquery/tree/master/samples |
0 commit comments