pkg

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSqlHelpersParameterLayer added in v0.1.5

func NewSqlHelpersParameterLayer() (*layers.ParameterLayerImpl, error)

func OpenDatabaseFromViper

func OpenDatabaseFromViper() (*sqlx.DB, error)

func RunNamedQueryIntoGlaze

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

func RunQueryIntoGlaze

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

Types

type ConnectionParameterLayer added in v0.1.5

type ConnectionParameterLayer struct {
	layers.ParameterLayerImpl
}

func NewSqlConnectionParameterLayer added in v0.1.5

func NewSqlConnectionParameterLayer() (*ConnectionParameterLayer, error)

func (*ConnectionParameterLayer) ParseFlagsFromCobraCommand added in v0.1.5

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

type DBConnectionFactory added in v0.1.5

type DBConnectionFactory func() (*sqlx.DB, error)

type DatabaseConfig

type DatabaseConfig struct {
	Host            string
	Database        string
	User            string
	Password        string
	Port            int
	Schema          string
	Type            string
	DSN             string
	Driver          string
	DbtProfilesPath string
	DbtProfile      string
	UseDbtProfiles  bool
}

func NewDatabaseConfigFromViper

func NewDatabaseConfigFromViper() *DatabaseConfig

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 added in v0.1.5

type DbtParameterLayer struct {
	layers.ParameterLayerImpl
}

func NewDbtParameterLayer added in v0.1.5

func NewDbtParameterLayer() (*DbtParameterLayer, error)

func (*DbtParameterLayer) ParseFlagsFromCobraCommand added in v0.1.5

func (d *DbtParameterLayer) ParseFlagsFromCobraCommand(_ *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

type SqlCommand

type SqlCommand struct {
	Query string
	// contains filtered or unexported fields
}

SqlCommand describes a command line command that runs a query

func NewSqlCommand

func NewSqlCommand(
	description *cmds.CommandDescription,
	factory DBConnectionFactory,
	query string,
) (*SqlCommand, error)

func (*SqlCommand) Description

func (s *SqlCommand) Description() *cmds.CommandDescription

func (*SqlCommand) IsValid

func (s *SqlCommand) IsValid() bool

func (*SqlCommand) RenderQuery

func (s *SqlCommand) RenderQuery(parameters map[string]interface{}) (string, error)

func (*SqlCommand) Run

func (s *SqlCommand) Run(ps map[string]interface{}, gp *cmds.GlazeProcessor) error

func (*SqlCommand) RunQueryIntoGlaze

func (s *SqlCommand) RunQueryIntoGlaze(
	ctx context.Context,
	db *sqlx.DB,
	parameters map[string]interface{},
	gp *cmds.GlazeProcessor) error

func (*SqlCommand) String

func (s *SqlCommand) String() string

type SqlCommandDescription

type SqlCommandDescription struct {
	Name      string                            `yaml:"name"`
	Short     string                            `yaml:"short"`
	Long      string                            `yaml:"long,omitempty"`
	Flags     []*parameters.ParameterDefinition `yaml:"flags,omitempty"`
	Arguments []*parameters.ParameterDefinition `yaml:"arguments,omitempty"`
	Layers    []layers.ParameterLayer           `yaml:"layers,omitempty"`

	Query string `yaml:"query"`
}

type SqlCommandLoader

type SqlCommandLoader struct {
	DBConnectionFactory DBConnectionFactory
}

func (*SqlCommandLoader) LoadCommandAliasFromYAML

func (scl *SqlCommandLoader) LoadCommandAliasFromYAML(s io.Reader) ([]*cmds.CommandAlias, error)

func (*SqlCommandLoader) LoadCommandFromYAML

func (scl *SqlCommandLoader) LoadCommandFromYAML(s io.Reader) ([]cmds.Command, error)

type SqletonCommand

type SqletonCommand interface {
	cmds.Command
	RunQueryIntoGlaze(ctx context.Context, db *sqlx.DB, parameters map[string]interface{}, gp *cmds.GlazeProcessor) error
	RenderQuery(parameters map[string]interface{}) (string, error)
}

Jump to

Keyboard shortcuts

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