sql

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2020 License: MIT Imports: 6 Imported by: 0

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

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

Jump to

Keyboard shortcuts

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