Learn about using the Go SDK for Firebolt.
The Firebolt Go SDK is an implementation of Go’s database/sql/driver
interface, enabling Go developers to connect to and interact with Firebolt databases seamlessly.
You must have the following prerequisites before you can connect your Firebolt account to Go:
To install the Firebolt Go SDK, run the following go get
command from inside your Go module:
Go passes a data source name (DSN) to Firebolt’s Go SDK to connect to Firebolt. The SDK parses the DSN string for parameters to authenticate and connect to a Firebolt account, database, and engine.
The DSN string supports the following parameters:
client_id
: client ID of your service account.client_secret
: client secret of your service account.account_name
: The name of your Firebolt account.database
: (Optional) The name of the database to connect to.engine
: (Optional) The name of the engine to run SQL queries on.The following is an example DSN string:
The Firebolt Go SDK can be used to connect to Firebolt Core. The connection process is the same, but the DSN parameters differ. For more information on connecting to Firebolt Core, refer to the Firebolt Core Go SDK documentation.
Just for a quick reference, the DSN for Firebolt Core should look like this:
To establish a connection to a Firebolt database, construct a DSN string with your credentials and database details. The following example contains a script to connect to Firebolt that you can place in a file (e.g main.go
) and run using go run main.go
inside your Go module:
Once connected, you can run SQL queries. The following examples show you how to create a table, insert data, and retrieve data. You can place them inside the previous script under `// Your database operations go here“:
Firebolt supports streaming large query results using rows.Next()
, allowing efficient processing of large datasets.
If you enable result streaming, the query execution might finish successfully, but the actual error might be returned while iterating the rows.
To enable streaming, use the firebolt-go-sdk/context
package to create a context with streaming enabled:
Streaming queries are particularly useful when dealing with large datasets, as they avoid loading the entire result set into memory at once.
When building a DSN to connect with Firebolt using the Go SDK, follow these best practices to ensure correct connection string formatting and avoid parsing errors. The DSN must follow this structure:
Guidelines
firebolt:///
.account_name
matches the name shown in the Firebolt Console URL, which is usually lowercase with no special characters.&database=
in the DSN.Error message | Likely cause | Solution |
---|---|---|
invalid connection string format | URI format is invalid or it contains illegal characters (like - ) | Double check the URI format and remove illegal characters. |
unknown parameter name database | Attempted to pass database as a query parameter. | Move the database name into the URI path. |
error opening database connection | Incorrect connection credentials. | Verify connection parameters values in the Firebolt UI and use exact values. |
Learn about using the Go SDK for Firebolt.
The Firebolt Go SDK is an implementation of Go’s database/sql/driver
interface, enabling Go developers to connect to and interact with Firebolt databases seamlessly.
You must have the following prerequisites before you can connect your Firebolt account to Go:
To install the Firebolt Go SDK, run the following go get
command from inside your Go module:
Go passes a data source name (DSN) to Firebolt’s Go SDK to connect to Firebolt. The SDK parses the DSN string for parameters to authenticate and connect to a Firebolt account, database, and engine.
The DSN string supports the following parameters:
client_id
: client ID of your service account.client_secret
: client secret of your service account.account_name
: The name of your Firebolt account.database
: (Optional) The name of the database to connect to.engine
: (Optional) The name of the engine to run SQL queries on.The following is an example DSN string:
The Firebolt Go SDK can be used to connect to Firebolt Core. The connection process is the same, but the DSN parameters differ. For more information on connecting to Firebolt Core, refer to the Firebolt Core Go SDK documentation.
Just for a quick reference, the DSN for Firebolt Core should look like this:
To establish a connection to a Firebolt database, construct a DSN string with your credentials and database details. The following example contains a script to connect to Firebolt that you can place in a file (e.g main.go
) and run using go run main.go
inside your Go module:
Once connected, you can run SQL queries. The following examples show you how to create a table, insert data, and retrieve data. You can place them inside the previous script under `// Your database operations go here“:
Firebolt supports streaming large query results using rows.Next()
, allowing efficient processing of large datasets.
If you enable result streaming, the query execution might finish successfully, but the actual error might be returned while iterating the rows.
To enable streaming, use the firebolt-go-sdk/context
package to create a context with streaming enabled:
Streaming queries are particularly useful when dealing with large datasets, as they avoid loading the entire result set into memory at once.
When building a DSN to connect with Firebolt using the Go SDK, follow these best practices to ensure correct connection string formatting and avoid parsing errors. The DSN must follow this structure:
Guidelines
firebolt:///
.account_name
matches the name shown in the Firebolt Console URL, which is usually lowercase with no special characters.&database=
in the DSN.Error message | Likely cause | Solution |
---|---|---|
invalid connection string format | URI format is invalid or it contains illegal characters (like - ) | Double check the URI format and remove illegal characters. |
unknown parameter name database | Attempted to pass database as a query parameter. | Move the database name into the URI path. |
error opening database connection | Incorrect connection credentials. | Verify connection parameters values in the Firebolt UI and use exact values. |