Sha256: c770743845a3a45e648421c95bae5c7d324f3756bc3a947628bb4a8834324e05

Contents?: true

Size: 1.33 KB

Versions: 16

Compression:

Stored size: 1.33 KB

Contents

// Copyright (c) 2017-2022 Snowflake Computing Inc. All rights reserved.

package gosnowflake

import (
	"context"
	"database/sql"
	"database/sql/driver"
	"os"
	"sync"
)

var paramsMutex *sync.Mutex

// SnowflakeDriver is a context of Go Driver
type SnowflakeDriver struct{}

// Open creates a new connection.
func (d SnowflakeDriver) Open(dsn string) (driver.Conn, error) {
	logger.Info("Open")
	ctx := context.TODO()
	cfg, err := ParseDSN(dsn)
	if err != nil {
		return nil, err
	}
	return d.OpenWithConfig(ctx, *cfg)
}

// OpenWithConfig creates a new connection with the given Config.
func (d SnowflakeDriver) OpenWithConfig(
	ctx context.Context,
	config Config) (
	driver.Conn, error) {
	if config.Tracing != "" {
		logger.SetLogLevel(config.Tracing)
	}
	logger.Info("OpenWithConfig")
	sc, err := buildSnowflakeConn(ctx, config)
	if err != nil {
		return nil, err
	}

	if err = authenticateWithConfig(sc); err != nil {
		return nil, err
	}
	sc.connectionTelemetry(&config)

	sc.startHeartBeat()
	sc.internal = &httpClient{sr: sc.rest}
	return sc, nil
}

func runningOnGithubAction() bool {
	return os.Getenv("GITHUB_ACTIONS") != ""
}

var logger = CreateDefaultLogger()

func init() {
	sql.Register("snowflake", &SnowflakeDriver{})
	logger.SetLogLevel("error")
	if runningOnGithubAction() {
		logger.SetLogLevel("fatal")
	}
	paramsMutex = &sync.Mutex{}
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby_snowflake_client-1.3.7 ext/vendor/github.com/snowflakedb/gosnowflake/driver.go
ruby_snowflake_client-1.3.6 ext/vendor/github.com/snowflakedb/gosnowflake/driver.go
ruby_snowflake_client-1.3.5 ext/vendor/github.com/snowflakedb/gosnowflake/driver.go
ruby_snowflake_client-1.3.4 ext/vendor/github.com/snowflakedb/gosnowflake/driver.go
ruby_snowflake_client-1.3.4.pre.debug ext/vendor/github.com/snowflakedb/gosnowflake/driver.go
ruby_snowflake_client-1.3.3.pre.debug ext/vendor/github.com/snowflakedb/gosnowflake/driver.go
ruby_snowflake_client-1.3.2 ext/vendor/github.com/snowflakedb/gosnowflake/driver.go
ruby_snowflake_client-1.3.1 ext/vendor/github.com/snowflakedb/gosnowflake/driver.go
ruby_snowflake_client-1.3.0 ext/vendor/github.com/snowflakedb/gosnowflake/driver.go
ruby_snowflake_client-1.2.1 ext/vendor/github.com/snowflakedb/gosnowflake/driver.go
ruby_snowflake_client-1.2.0 ext/vendor/github.com/snowflakedb/gosnowflake/driver.go
ruby_snowflake_client-1.1.1 ext/vendor/github.com/snowflakedb/gosnowflake/driver.go
ruby_snowflake_client-1.1.0 ext/vendor/github.com/snowflakedb/gosnowflake/driver.go
ruby_snowflake_client-1.0.2 ext/vendor/github.com/snowflakedb/gosnowflake/driver.go
ruby_snowflake_client-1.0.1 ext/vendor/github.com/snowflakedb/gosnowflake/driver.go
ruby_snowflake_client-1.0.0 ext/vendor/github.com/snowflakedb/gosnowflake/driver.go