Skip to content

Commit ad211b4

Browse files
committed
docs: added auth info, fixed connstring examples
1 parent 667ca4e commit ad211b4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

README.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# BigQuery SQL Driver for Golang
22
This is an implementation of the BigQuery Client as a database/sql/driver for easy integration and usage.
33

4-
54
# Goals of project
65

76
This project is meant to be a basic database/sql driver implementation for Golang so that developers can easily use
@@ -11,9 +10,19 @@ tools like Gorm, and *sql.DB functions, with Google's BigQuery database.
1110

1211
Check out the example application in the `examples` directory, for a few examples.
1312

13+
# Authentication
14+
1415
As this is using the Google Cloud Go SDK, you will need to have your credentials available
1516
via the GOOGLE_APPLICATION_CREDENTIALS environment variable point to your credential JSON file.
1617

18+
Alternatively, you can specify `apiKey` connection string parameter with API key value,
19+
or `credentials` parameter with base-64 encoded service account or refresh token JSON credentials as the value.
20+
Connection string examples:
21+
```js
22+
"bigquery://projectid/location/dataset?apiKey=AIzaSyB6XK8IO5AzKZXoioQOVNTFYzbDBjY5hy4"
23+
"bigquery://projectid/location/dataset?credentials=eyJ0eXBlIjoiYXV0..."
24+
```
25+
1726
## Vanilla *sql.DB usage
1827

1928
Just like any other database/sql driver you'll need to import it
@@ -29,7 +38,7 @@ import (
2938

3039
func main() {
3140
db, err := sql.Open("bigquery",
32-
"bigquery://projectid/dataset")
41+
"bigquery://projectid/location/dataset")
3342
if err != nil {
3443
log.Fatal(err)
3544
}
@@ -54,7 +63,7 @@ import (
5463

5564
func main() {
5665
db, err := gorm.Open("bigquery",
57-
"bigquery://projectid/dataset")
66+
"bigquery://projectid/location/dataset")
5867
if err != nil {
5968
log.Fatal(err)
6069
}

0 commit comments

Comments
 (0)