sql

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2020 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultQueryBuilder

type DefaultQueryBuilder struct{}

DefaultQueryBuilder when no Builder is provided to Worker , this implementation is used

func (*DefaultQueryBuilder) Insert

func (d *DefaultQueryBuilder) Insert(table string, cols []string) string

Insert implements QueryBuilder interface nolint gosec

type QueryBuilder

type QueryBuilder interface {
	//Insert create a new insert statement with given table and colums
	Insert(table string, cols []string) string
}

QueryBuilder define methods to build SQL queries for database operations

type Reader

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

Reader a Worker that execute a given Query and export data via output channel

func NewReader

func NewReader(opts ReaderOptions) *Reader

NewReader create a new Reader with given options

func (*Reader) Process

func (s *Reader) Process(ctx context.Context, args selina.ProcessArgs) (err error)

Process implements Worker interface

type ReaderOptions

type ReaderOptions struct {
	//Driver which driver should be used
	//this require that users import required driver
	Driver string
	//ConnStr connection string relative to Driver
	ConnStr string
	//Query which SQL select will be executed into database
	Query string
}

ReaderOptions provide parameters to create a Reader

func (ReaderOptions) Check added in v0.8.0

func (o ReaderOptions) Check() error

Check if a combination of options is valid this not guarantees that worker will not fail

type Writer

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

Writer a Worker that insert data into database

func NewWriter

func NewWriter(opts WriterOptions) *Writer

NewWriter create a new Writer with given options

func (*Writer) Process

func (s *Writer) Process(ctx context.Context, args selina.ProcessArgs) error

Process implements Worker interface

type WriterOptions

type WriterOptions struct {
	//Driver which driver should be used
	//this require that users import required driver
	Driver string
	//ConnStr connection string relative to Driver
	ConnStr string
	//Table in which table data will be inserted
	Table string
	//Builder (optional) customize SQL generation
	Builder QueryBuilder
}

WriterOptions provide parameters to create a Writer

func (WriterOptions) Check added in v0.8.0

func (o WriterOptions) Check() error

Check if a combination of options is valid this not guarantees that worker will not fail

Jump to

Keyboard shortcuts

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