snowflake

package module
v0.0.0-...-5a194fd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureSnowflakeDB

func ConfigureSnowflakeDB(s *Config) (*sql.DB, error)

func DSN

func DSN(conf *Config) (string, error)

func ExecMulti

func ExecMulti(ctx context.Context, db *sql.DB, queries []string) error

func ExecNoRows

func ExecNoRows(ctx context.Context, db *sql.DB, query string) (sql.Result, error)

func Open

func Open(dsn string) (*sql.DB, error)

func Query

func Query(ctx context.Context, db *sql.DB, stmt string) (*sqlx.Rows, error)

Query will run stmt against the db and return the rows. We use [DB.Unsafe](https://godoc.org/github.com/jmoiron/sqlx#DB.Unsafe) so that we can scan to structs without worrying about newly introduced columns

func QueryRow

func QueryRow(ctx context.Context, db *sql.DB, stmt string, args ...interface{}) *sqlx.Row

QueryRow will run stmt against the db and return the row. We use [DB.Unsafe](https://godoc.org/github.com/jmoiron/sqlx#DB.Unsafe) so that we can scan to structs without worrying about newly introduced columns

func RSAKeypairToString

func RSAKeypairToString(rsaPrivKey *rsa.PrivateKey) (snowflakePrivateKey string, snowflakePublicKey string, err error)

Formatting based on requirements here: https://docs.snowflake.com/en/user-guide/key-pair-auth.html Important parts:

  • pkcs8 format
  • 2048 bits
  • pem encoding
  • no whitespace and headers in private key string
  • base64 encoding

Types

type Config

type Config struct {
	Account          string `yaml:"account"`
	User             string `yaml:"username"`
	Password         string `yaml:"password"`
	BrowserAuth      bool   `yaml:"browser_auth"`
	PrivateKeyPath   string `yaml:"private_key_path"`
	PrivateKeyBytes  []byte `yaml:"private_key"`
	OauthAccessToken string `yaml:"oauth_access_token"`
	Region           string `yaml:"region"`
	Role             string `yaml:"role"`
	Warehouse        string `yaml:"warehouse"`
}

type User

type User struct {
	Comment          sql.NullString `db:"comment"`
	DefaultNamespace sql.NullString `db:"default_namespace"`
	DefaultRole      sql.NullString `db:"default_role"`
	DefaultWarehouse sql.NullString `db:"default_warehouse"`
	Disabled         bool           `db:"disabled"`
	DisplayName      sql.NullString `db:"display_name"`
	Email            sql.NullString `db:"email"`
	FirstName        sql.NullString `db:"first_name"`
	HasRsaPublicKey  bool           `db:"has_rsa_public_key"`
	LastName         sql.NullString `db:"last_name"`
	LoginName        sql.NullString `db:"login_name"`
	Name             sql.NullString `db:"name"`
}

func ScanUser

func ScanUser(row *sqlx.Row) (*User, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL