This is an implementation of the BigQuery Client as a database/sql/driver
for easy integration and usage.
This project is meant to be a basic database/sql
driver implementation for Golang so that developers can easily use
*sql.DB
functions with Google's BigQuery database.
Unlike the original project, this driver
- does not contain ORM extension
- uses different connection string
The connection string format is URL with bigquery
scheme and host representing project ID.
Path (optional) represents location (cloud region).
bigquery://projectid/?param1=value¶m2=value
bigquery://projectid/location?param1=value¶m2=value
dataset
- dataset ID. When set, it allows to use unqualified tables names in queries.
As this is using the Google Cloud Go SDK, you will need to have your credentials available via the GOOGLE_APPLICATION_CREDENTIALS environment variable point to your credential JSON file.
Alternatively, you can use one of the following parameters:
apiKey
- API key valuecredentials
- base-64 encoded service account or refresh token JSON credentials
Examples:
bigquery://projectid/?apiKey=AIzaSyB6XK8IO5AzKZXoioQOVNTFYzbDBjY5hy4
bigquery://projectid/?credentials=eyJ0eXBlIjoiYXV0...
package main
import "github.com/bonitoo-io/go-sql-bigquery"
func main() {
db, err := sql.Open("bigquery", "bigquery://lunar-1234/?dataset=storeys")
if err != nil {
log.Fatal(err)
}
defer db.Close()
...
}
Contributions are welcome.
-
driver.Conn
implemented -
driver.Querier
implemented -
driver.Pinger
implemented -
driver.DriverContext
implemented -
driver.QueryerContext
implemented -
driver.ExecerContext
implemented -
driver.RowsColumnTypeDatabaseTypeName
implemented - Prepared Statements - supported via a quick hack
- Parameterized Queries