1
1
# BigQuery SQL Driver for Golang
2
2
This is an implementation of the BigQuery Client as a database/sql/driver for easy integration and usage.
3
3
4
-
5
4
# Goals of project
6
5
7
6
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.
11
10
12
11
Check out the example application in the ` examples ` directory, for a few examples.
13
12
13
+ # Authentication
14
+
14
15
As this is using the Google Cloud Go SDK, you will need to have your credentials available
15
16
via the GOOGLE_APPLICATION_CREDENTIALS environment variable point to your credential JSON file.
16
17
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
+
17
26
## Vanilla * sql.DB usage
18
27
19
28
Just like any other database/sql driver you'll need to import it
@@ -29,7 +38,7 @@ import (
29
38
30
39
func main () {
31
40
db , err := sql.Open (" bigquery" ,
32
- " bigquery://projectid/dataset" )
41
+ " bigquery://projectid/location/ dataset" )
33
42
if err != nil {
34
43
log.Fatal (err)
35
44
}
@@ -54,7 +63,7 @@ import (
54
63
55
64
func main () {
56
65
db , err := gorm.Open (" bigquery" ,
57
- " bigquery://projectid/dataset" )
66
+ " bigquery://projectid/location/ dataset" )
58
67
if err != nil {
59
68
log.Fatal (err)
60
69
}
0 commit comments