sql

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 25 Imported by: 5

Documentation

Index

Constants

View Source
const DbtSlug = "dbt"
View Source
const SqlConnectionSlug = "sql-connection"

Variables

This section is empty.

Functions

func BuildCobraCommandWithSqletonMiddlewares added in v0.1.0

func BuildCobraCommandWithSqletonMiddlewares(
	cmd cmds.Command,
	options ...cli.CobraParserOption,
) (*cobra.Command, error)

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

func GetCobraCommandSqletonMiddlewares(
	commandSettings *cli.GlazedCommandSettings,
	cmd *cobra.Command,
	args []string,
) ([]middlewares.Middleware, error)

func OpenDatabaseFromDefaultSqlConnectionLayer

func OpenDatabaseFromDefaultSqlConnectionLayer(
	parsedLayers *layers.ParsedLayers,
) (*sqlx.DB, error)

func OpenDatabaseFromSqlConnectionLayer

func OpenDatabaseFromSqlConnectionLayer(
	parsedLayers *layers.ParsedLayers,
	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,
	data 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,
	ps2 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 DBConnectionFactory added in v0.1.0

type DBConnectionFactory func(parsedLayers *layers.ParsedLayers) (*sqlx.DB, 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.ParsedLayer) (*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)

type DbtSettings added in v0.1.0

type DbtSettings struct {
	DbtProfilesPath string `glazed.parameter:"dbt-profiles-path"`
	UseDbtProfiles  bool   `glazed.parameter:"use-dbt-profiles"`
	DbtProfile      string `glazed.parameter:"dbt-profile"`
}

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

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

func NewSqlConnectionParameterLayer

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

type SqlConnectionSettings added in v0.1.0

type SqlConnectionSettings struct {
	Host       string `glazed.parameter:"host"`
	Port       int    `glazed.parameter:"port"`
	Database   string `glazed.parameter:"database"`
	User       string `glazed.parameter:"user"`
	Password   string `glazed.parameter:"password"`
	Schema     string `glazed.parameter:"schema"`
	DbType     string `glazed.parameter:"db-type"`
	Repository string `glazed.parameter:"repository"`
	Dsn        string `glazed.parameter:"dsn"`
	Driver     string `glazed.parameter:"driver"`
}

Jump to

Keyboard shortcuts

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