sql

package
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 22 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanQuery added in v0.0.21

func CleanQuery(query string) string

func CreateTemplate

func CreateTemplate(
	ctx context.Context,
	subQueries map[string]string,
	ps map[string]interface{},
	db *sqlx.DB,
) *template.Template

func OpenDatabaseFromDefaultSqlConnectionLayer

func OpenDatabaseFromDefaultSqlConnectionLayer(
	parsedLayers map[string]*layers.ParsedParameterLayer,
) (*sqlx.DB, error)

func OpenDatabaseFromParsedLayers

func OpenDatabaseFromParsedLayers(parsedLayers ...*layers.ParsedParameterLayer) (*sqlx.DB, error)

func OpenDatabaseFromSqlConnectionLayer

func OpenDatabaseFromSqlConnectionLayer(
	parsedLayers map[string]*layers.ParsedParameterLayer,
	sqlConnectionLayerName string,
	dbtLayerName string,
) (*sqlx.DB, error)

func RenderQuery added in v0.0.28

func RenderQuery(
	ctx context.Context,
	db *sqlx.DB,
	query string,
	subQueries map[string]string,
	ps map[string]interface{},
) (string, error)

func RunNamedQueryIntoGlaze

func RunNamedQueryIntoGlaze(
	dbContext context.Context,
	db *sqlx.DB,
	query string,
	parameters map[string]interface{},
	gp middlewares.Processor) error

func RunQuery

func RunQuery(
	ctx context.Context,
	subQueries map[string]string,
	query string,
	args []interface{},
	ps map[string]interface{},
	db *sqlx.DB,
) (string, *sqlx.Rows, error)

func RunQueryIntoGlaze

func RunQueryIntoGlaze(
	dbContext context.Context,
	db *sqlx.DB,
	query string,
	parameters []interface{},
	gp middlewares.Processor) error

Types

type ConnectionParameterLayer

type ConnectionParameterLayer struct {
	layers.ParameterLayerImpl `yaml:",inline"`
}

func NewSqlConnectionParameterLayer

func NewSqlConnectionParameterLayer(
	options ...layers.ParameterLayerOptions,
) (*ConnectionParameterLayer, error)

func (*ConnectionParameterLayer) ParseFlagsFromCobraCommand

func (cp *ConnectionParameterLayer) ParseFlagsFromCobraCommand(cmd *cobra.Command) (map[string]interface{}, error)

type DatabaseConfig

type DatabaseConfig struct {
	Host            string `glazed.parameter:"host"`
	Database        string `glazed.parameter:"database"`
	User            string `glazed.parameter:"user"`
	Password        string `glazed.parameter:"password"`
	Port            int    `glazed.parameter:"port"`
	Schema          string `glazed.parameter:"schema"`
	Type            string `glazed.parameter:"db-type"`
	DSN             string `glazed.parameter:"dsn"`
	Driver          string `glazed.parameter:"driver"`
	DbtProfilesPath string `glazed.parameter:"dbt-profiles-path"`
	DbtProfile      string `glazed.parameter:"dbt-profile"`
	UseDbtProfiles  bool   `glazed.parameter:"use-dbt-profiles"`
}

func NewConfigFromParsedLayers

func NewConfigFromParsedLayers(parsedLayers ...*layers.ParsedParameterLayer) (*DatabaseConfig, error)

func (*DatabaseConfig) Connect

func (c *DatabaseConfig) Connect() (*sqlx.DB, error)

func (*DatabaseConfig) GetSource

func (c *DatabaseConfig) GetSource() (*Source, error)

func (*DatabaseConfig) LogVerbose

func (c *DatabaseConfig) LogVerbose()

LogVerbose just outputs information about the database config to the debug logging level.

func (*DatabaseConfig) ToString

func (c *DatabaseConfig) ToString() string

type DbtParameterLayer

type DbtParameterLayer struct {
	layers.ParameterLayerImpl `yaml:",inline"`
}

func NewDbtParameterLayer

func NewDbtParameterLayer(
	options ...layers.ParameterLayerOptions,
) (*DbtParameterLayer, error)

func (*DbtParameterLayer) ParseFlagsFromCobraCommand

func (d *DbtParameterLayer) ParseFlagsFromCobraCommand(cmd *cobra.Command) (map[string]interface{}, error)

type Source

type Source struct {
	Name     string
	Type     string `yaml:"type"`
	Hostname string `yaml:"server"`
	Port     int    `yaml:"port"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	Schema   string `yaml:"schema"`
	Database string `yaml:"database"`
}

Source is the generic structure we use to represent a database connection string

func ParseDbtProfiles

func ParseDbtProfiles(profilesPath string) ([]*Source, error)

ParseDbtProfiles parses a dbt profiles.yml file and returns a map of sources

func (*Source) ToConnectionString

func (s *Source) ToConnectionString() string

Jump to

Keyboard shortcuts

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