db

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrQueryTimeout indicates that time for executing query is out.
	ErrQueryTimeout = errors.New("time for executing query is out")
	// ErrNotExistColumn indicates that given column doesn't exist.
	ErrNotExistColumn = errors.New("column doesn't exist")
	// ErrTableConnection indicates that executor can't connect to the given table.
	ErrTableConnection = errors.New("can't connect table")
	// ErrTableDisconnection indicates that executor can't disconnect the table.
	ErrTableDisconnection = errors.New("can't disconnect table")
	// ErrTableColumnsRead indicates that executor can't read the table columns.
	ErrTableColumnsRead = errors.New("can't read table columns")
	// ErrIncorrectTableRow indicates that executor got incorrect table row.
	ErrIncorrectTableRow = errors.New("incorrect table row")
	// ErrIncorrectWhereTree indicates that executor got incorrect where tree.
	ErrIncorrectWhereTree = errors.New("incorrect where tree")
	// ErrIncorrectColumnOrder indicates that executor got incorrect column order in tables.
	ErrIncorrectColumnOrder = errors.New("incorrect column order in tables")
	// ErrIncorrectColumnCount indicates that executor got incorrect column count.
	ErrIncorrectColumnCount = errors.New("incorrect column count")
)

Functions

func Execute

func Execute(ctx context.Context, connector TableConnector, queryString string, conf *config.Config, logger *zap.Logger) error

Execute executes query.

Types

type DB

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

DB describes file database.

func NewDB

func NewDB(connector TableConnector, query *csvquery.Query, logger *zap.Logger, conf *config.Config) *DB

NewDB returns new instance of DB.

type FileTableConnector

type FileTableConnector struct{}

FileTableConnector implements TableConnector interface for working with files.

func (FileTableConnector) Exists

func (c FileTableConnector) Exists(tablePath string) bool

Exists checks whether a file exists.

func (FileTableConnector) GetReader

func (c FileTableConnector) GetReader(tablePath string) (io.ReadCloser, error)

GetReader returns file reader.

type Table

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

Table describes table entity.

func NewTable

func NewTable(
	name csvquery.Table,
	query *csvquery.Query,
	db *DB,
) *Table

NewTable returns new instance of Table.

func (*Table) Exists

func (t *Table) Exists() bool

Exists checks whether a table exists.

type TableConnector

type TableConnector interface {
	GetReader(string) (io.ReadCloser, error)
	Exists(string) bool
}

TableConnector is the interface that groups the basic GetReader and Exists methods.

Jump to

Keyboard shortcuts

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