snowflake

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// SNOWFLAKE_TABLES_LIST_QUERY is the query to list tables in Snowflake.
	SNOWFLAKE_TABLES_LIST_QUERY = "SELECT table_name FROM %s.information_schema.tables WHERE table_schema = '%s';"
	// SNOWFLAKE_SCHEMA_QUERY is the query to retrieve schema information for a table in Snowflake.
	SNOWFLAKE_SCHEMA_QUERY = "SELECT column_name::TEXT, data_type::TEXT FROM information_schema.columns WHERE table_name::TEXT = ?;"
)

Variables

View Source
var DB_PASSWORD string = "DB_PASSWORD"

DB_PASSWORD is the environment variable name for the database password.

Functions

func NewSnowflake

func NewSnowflake(dbClient *sql.DB) (types.ISQL, error)

NewSnowflake creates a new Snowflake object with an initialized database client and configuration.

func NewSnowflakeWithConfig

func NewSnowflakeWithConfig(config *config.Config) (types.ISQL, error)

NewSnowflakeWithConfig creates a new Snowflake object with an initialized database client and configuration.

Types

type Snowflake

type Snowflake struct {
	Client *sql.DB        // Client is the database client for Snowflake.
	Config *config.Config // Config is the configuration for Snowflake.
}

Snowflake is a Snowflake implementation of the ISQL interface.

func (*Snowflake) Execute

func (s *Snowflake) Execute(query string) ([]byte, error)

Execute executes a query on a Snowflake database and returns the result as a JSON byte slice.

func (*Snowflake) GenerateCreateTableQuery

func (s *Snowflake) GenerateCreateTableQuery(table types.Table) string

GenerateCreateTableQuery generates a CREATE TABLE query for Snowflake. It takes a Table struct as an argument and returns the query as a string.

func (*Snowflake) Schema

func (s *Snowflake) Schema(table string) (types.Table, error)

Schema returns the schema of a table in Snowflake. It takes the table name as an argument and returns a Table struct and an error if any.

func (*Snowflake) Tables

func (s *Snowflake) Tables(databaseName string) ([]string, error)

Tables returns a list of tables in a Snowflake database. It takes the database name as an argument and returns a slice of table names.

Jump to

Keyboard shortcuts

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