database

package
v1.50.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package database defines functions to be used by the Snowflake exporter for interacting with Snowflake

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	InitDatabaseConn(ctx context.Context, roles string) error
	CreateSchema(ctx context.Context, schema string) error
	CreateTable(ctx context.Context, sql string) error
	BatchInsert(ctx context.Context, data []map[string]any, sql string) error
	Close() error
}

Database defines functions to use to interact with a database

func CreateSnowflakeDatabase

func CreateSnowflakeDatabase(dsn, wh, db string) (Database, error)

CreateSnowflakeDatabase calls Open() using driverName and the given dsn and then calls Ping()

type Snowflake

type Snowflake struct {
	// contains filtered or unexported fields
}

Snowflake implements the Database type

func (*Snowflake) BatchInsert

func (s *Snowflake) BatchInsert(ctx context.Context, data []map[string]any, sql string) error

BatchInsert creates a new transaction using the given DB to insert the given data

func (*Snowflake) Close

func (s *Snowflake) Close() error

Close ensures the db is closed if it exists

func (*Snowflake) CreateSchema

func (s *Snowflake) CreateSchema(ctx context.Context, schema string) error

CreateSchema ensures the given schema exists using the given *sql.DB

func (*Snowflake) CreateTable

func (s *Snowflake) CreateTable(ctx context.Context, sql string) error

CreateTable ensures the given table exists using the given database arguments

func (*Snowflake) InitDatabaseConn

func (s *Snowflake) InitDatabaseConn(ctx context.Context, role string) error

InitDatabaseConn initializes the Snowflake connection by ensuring the correct role is used, database exists and is used by the connection, and that the warehouse will be used.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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