Categorygithub.com/sigmacomputing/gosnowflake
modulepackage
1.1.13
Repository: https://github.com/sigmacomputing/gosnowflake.git
Documentation: pkg.go.dev

# README


Go Snowflake Driver


.. image:: https://travis-ci.org/snowflakedb/gosnowflake.svg?branch=master :target: https://travis-ci.org/snowflakedb/gosnowflake

.. image:: https://codecov.io/gh/snowflakedb/gosnowflake/branch/master/graph/badge.svg :target: https://codecov.io/gh/snowflakedb/gosnowflake

.. image:: http://img.shields.io/:license-Apache%202-brightgreen.svg :target: http://www.apache.org/licenses/LICENSE-2.0.txt

.. image:: https://goreportcard.com/badge/github.com/snowflakedb/gosnowflake :target: https://goreportcard.com/report/github.com/snowflakedb/gosnowflake

This topic provides instructions for installing, running, and modifying the Go Snowflake Driver. The driver supports Go's database/sql <https://golang.org/pkg/database/sql/>_ package.

Prerequisites

The following software packages are required to use the Go Snowflake Driver.

Go

The driver requires the Go language <https://golang.org/>_ 1.8 or higher. The supported operating systems are Linux, Mac OS, and Windows, but you may run the driver on other platforms if the Go language works correctly on those platforms.

Installation

Get Gosnowflake source code and dep <https://github.com/golang/dep>_ (dependency managment tool), if not installed, and ensure the dependent libraries are installed.

.. code-block:: bash

go get -u github.com/snowflakedb/gosnowflake
go get -u github.com/golang/dep/cmd/dep
cd $GOPATH/src/github.com/snowflakedb/gosnowflake/
dep ensure

Logging Settings

Unless you implement your own glog and would like to plug in that glog to dump messages generated from the Gosnowflake driver, we strongly recommend using snowflake's implementation of glog.

To use snowflake's glog, add the following block to your Gopkg.toml

.. code-block::

[[override]]
name = "github.com/golang/glog"
source = "https://github.com/snowflakedb/glog.git"
revision = "f5055e6f21ce71153a199e6460664045b3af8e50"

Run dep ensure to download the snowflake's glog

Docs

For detailed documentation and basic usage examples, please see the documentation at godoc.org <https://godoc.org/github.com/snowflakedb/gosnowflake/>_.

Sample Programs

Snowflake provides a set of sample programs to test with. Set the environment variable $GOPATH to the top directory of your workspace, e.g., ~/go and make certain to include $GOPATH/bin in the environment variable $PATH. Run the make command to build all sample programs.

.. code-block:: go

make install

In the following example, the program select1.go is built and installed in $GOPATH/bin and can be run from the command line:

.. code-block:: bash

SNOWFLAKE_TEST_ACCOUNT=<your_account> \
SNOWFLAKE_TEST_USER=<your_user> \
SNOWFLAKE_TEST_PASSWORD=<your_password> \
select1
Congrats! You have successfully run SELECT 1 with Snowflake DB!

Development

The developer notes are hosted with the source code on GitHub <https://github.com/snowflakedb/gosnowflake>_.

Testing Code

Set the Snowflake connection info in parameters.json:

.. code-block:: json

{
    "testconnection": {
        "SNOWFLAKE_TEST_USER":      "<your_user>",
        "SNOWFLAKE_TEST_PASSWORD":  "<your_password>",
        "SNOWFLAKE_TEST_ACCOUNT":   "<your_account>",
        "SNOWFLAKE_TEST_WAREHOUSE": "<your_warehouse>",
        "SNOWFLAKE_TEST_DATABASE":  "<your_database>",
        "SNOWFLAKE_TEST_SCHEMA":    "<your_schema>",
        "SNOWFLAKE_TEST_ROLE":      "<your_role>"
    }
}

Install jq <https://stedolan.github.io/jq/>_ so that the parameters can get parsed correctly, and run make test in your Go development environment:

.. code-block:: bash

make test

Submitting Pull Requests

You may use your preferred editor to edit the driver code. Make certain to run make fmt lint before submitting any pull request to Snowflake. This command formats your source code according to the standard Go style and detects any coding style issues.

Support

For official support, contact Snowflake support at: https://support.snowflake.net/s/snowflake-support

# Packages

No description provided by the author
No description provided by the author

# Functions

DSN constructs a DSN for Snowflake db.
Location returns an offset (minutes) based Location object for Snowflake database.
LocationWithOffsetString returns an offset based Location object.
ParseDSN parses the DSN string to a Config.
ScanSnowflakeParameter binds SnowflakeParameter variable with an array of column buffer.

# Constants

ErrCodeEmptyAccountCode is an error code for the case where a DNS doesn't include account parameter.
ErrCodeEmptyPasswordCode is an error code for the case where a DNS doesn't include password parameter.
ErrCodeEmptyUsernameCode is an error code for the case where a DNS doesn't include user parameter.
ErrCodeFailedToConnect is an error code for the case where a DB connection failed due to wrong account name.
ErrCodeFailedToParseHost is an error code for the case where a DNS includes an invalid host name.
ErrCodeFailedToParsePort is an error code for the case where a DNS includes an invalid port number.
ErrCodeIdpConnectionError is an error code for the case where a IDP connection failed.
ErrCodeObjectNotExists is an error code for the case where the specified database object doesn't exist.
ErrCodePrivateKeyParseError is an error code for the case where the private key is not parsed correctly.
ErrCodeServiceUnavailable is an error code for the case where service is unavailable.
ErrCodeSSOURLNotMatch is an error code for the case where a SSO URL doesn't match.
ErrFailedToAuth is an error code for the case where authentication failed for unknown reason.
ErrFailedToAuthOKTA is an error code for the case where authentication via OKTA failed for unknown reason.
ErrFailedToAuthSAML is an error code for the case where authentication via SAML failed for unknown reason.
ErrFailedToCancelQuery is an error code for the case where cancel query failed.
ErrFailedToCloseSession is an error code for the case where close session failed.
ErrFailedToGetChunk is an error code for the case where it failed to get chunk of result set.
ErrFailedToGetExternalBrowserResponse is an error code for when there's an error reading from the open socket.
ErrFailedToGetSSO is an error code for the case where authentication via OKTA failed for unknown reason.
ErrFailedToHeartbeat is an error code when a heartbeat fails.
ErrFailedToParseResponse is an error code for when we cannot parse an external browser response from Snowflake.
ErrFailedToPostQuery is an error code for the case where HTTP POST failed.
ErrFailedToRenewSession is an error code for the case where session renewal failed.
ErrInvalidBinaryHexForm is an error code for the case where a binary data in hex form is invalid.
ErrInvalidOffsetStr is an error code for the case where a offset string is invalid.
ErrInvalidTimestampTz is an error code for the case where a returned TIMESTAMP_TZ internal value is invalid.
ErrNoDefaultTransactionIsolationLevel is an error code for the case where non default isolation level is specified.
ErrNoReadOnlyTransaction is an error code for the case where readonly mode is specified.
SnowflakeGoDriverVersion is the version of Go Snowflake Driver.
SQLStateConnectionFailure is a SQL State code indicating connection failed.
SQLStateConnectionRejected is a SQL State code indicating connection was rejected.
SQLStateConnectionWasNotEstablished is a SQL State code indicating connection was not established.
SQLStateFeatureNotSupported is a SQL State code indicating the feature is not enabled.
SQLStateInvalidDataTimeFormat is a SQL State code indicating DataTime format is invalid.
SQLStateNumericValueOutOfRange is a SQL State code indicating Numeric value is out of range.

# Variables

CustomJSONDecoderEnabled has the chunk downloader use the custom JSON decoder to reduce memory footprint.
DataTypeArray is a ARRAY datatype.
DataTypeBinary is a BINARY datatype.
DataTypeBoolean is a BOOLEAN datatype.
DataTypeDate is a Date datatype.
DataTypeFixed is a FIXED datatype.
DataTypeObject is a OBJECT datatype.
DataTypeReal is a REAL datatype.
DataTypeText is a TEXT datatype.
DataTypeTime is a TIME datatype.
DataTypeTimestampLtz is a TIMESTAMP_LTZ datatype.
DataTypeTimestampNtz is a TIMESTAMP_NTZ datatype.
DataTypeTimestampTz is a TIMESTAMP_TZ datatype.
DataTypeVariant is a TEXT datatype.
ErrEmptyAccount is returned if a DNS doesn't include account parameter.
ErrEmptyPassword is returned if a DNS doesn't include password parameter.
ErrEmptyUsername is returned if a DNS doesn't include user parameter.
MaxChunkDownloadWorkers specifies the maximum number of goroutines used to download chunks.
SnowflakeTransport includes the certificate revocation check with OCSP in parallel.
SnowflakeTransportSerial includes the certificate revocation check with OCSP in serial.
SnowflakeTransportTest includes the certificate revocation check in parallel.

# Structs

Config is a set of configuration parameters.
SnowflakeDriver is a context of Go Driver.
SnowflakeError is a error type including various Snowflake specific information.
SnowflakeParameter includes the columns output from SHOW PARAMETER command.