dbEngine

package
v1.0.325 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildSqlOptions added in v1.0.303

type BuildSqlOptions func(b *SQLBuilder) error

func ArgsForSelect added in v1.0.303

func ArgsForSelect(args ...interface{}) BuildSqlOptions

func ColumnsForSelect added in v1.0.303

func ColumnsForSelect(columns ...string) BuildSqlOptions

func WhereForSelect added in v1.0.303

func WhereForSelect(columns ...string) BuildSqlOptions

type Column

type Column interface {
	BasicType() types.BasicKind
	BasicTypeInfo() types.BasicInfo
	CheckAttr(fieldDefine string) string
	CharacterMaximumLength() int
	Comment() string
	Name() string
	Primary() bool
	Type() string
	Required() bool
	SetNullable(bool)
}

func SimpleColumns added in v1.0.296

func SimpleColumns(names ...string) []Column

type Connection added in v1.0.301

type Connection interface {
	InitConn(ctx context.Context, dbURL string) error
	GetSchema(ctx context.Context) (map[string]Table, map[string]Routine, error)
	GetStat() string
	ExecDDL(ctx context.Context, sql string, args ...interface{}) error
	NewTable(name, typ string) Table
}

type DB

type DB struct {
	Cfg      map[string]interface{}
	Conn     Connection
	Tables   map[string]Table
	Routines map[string]Routine
}

func NewDB added in v1.0.301

func NewDB(ctx context.Context, conn Connection) (*DB, error)

func (*DB) ReadTableSQL added in v1.0.301

func (db *DB) ReadTableSQL(path string, info os.FileInfo, err error) error

type ErrNotFoundColumn added in v1.0.303

type ErrNotFoundColumn struct {
	Table  string
	Column string
}

ErrNotFoundColumn if not found in table {Table} field by name {Column}

func NewErrNotFoundColumn added in v1.0.303

func NewErrNotFoundColumn(table string, column string) *ErrNotFoundColumn

func (ErrNotFoundColumn) Error added in v1.0.303

func (err ErrNotFoundColumn) Error() string

type ErrNotFoundTable added in v1.0.301

type ErrNotFoundTable struct {
	Table string
}

ErrNotFoundTable if not found table by name {Table}

func (ErrNotFoundTable) Error added in v1.0.301

func (err ErrNotFoundTable) Error() string

type ErrWrongArgsLen added in v1.0.303

type ErrWrongArgsLen struct {
	Table  string
	Filter []string
	Args   []interface{}
}

ErrNotFoundColumn if not found in table {Table} field by name {Column}

func NewErrWrongArgsLen added in v1.0.303

func NewErrWrongArgsLen(table string, column []string, args []interface{}) *ErrWrongArgsLen

func (ErrWrongArgsLen) Error added in v1.0.303

func (err ErrWrongArgsLen) Error() string

type FncEachRow added in v1.0.303

type FncEachRow func(values []interface{}, columns []Column) error

type Index added in v1.0.301

type Index struct {
	Name    string
	Columns []string
}

type NumberColumn added in v1.0.296

type NumberColumn struct {
	IsNullable bool
	// contains filtered or unexported fields
}

func NewNumberColumn added in v1.0.296

func NewNumberColumn(name, comment string, req bool) *NumberColumn

func (*NumberColumn) BasicType added in v1.0.301

func (s *NumberColumn) BasicType() types.BasicKind

func (*NumberColumn) BasicTypeInfo added in v1.0.301

func (s *NumberColumn) BasicTypeInfo() types.BasicInfo

func (*NumberColumn) CharacterMaximumLength added in v1.0.296

func (s *NumberColumn) CharacterMaximumLength() int

func (*NumberColumn) CheckAttr added in v1.0.301

func (s *NumberColumn) CheckAttr(fieldDefine string) string

func (*NumberColumn) Comment added in v1.0.296

func (s *NumberColumn) Comment() string

func (*NumberColumn) Name added in v1.0.296

func (s *NumberColumn) Name() string

func (*NumberColumn) Primary added in v1.0.321

func (c *NumberColumn) Primary() bool

func (*NumberColumn) Required added in v1.0.296

func (s *NumberColumn) Required() bool

func (*NumberColumn) SetNullable added in v1.0.301

func (c *NumberColumn) SetNullable(f bool)

func (*NumberColumn) Type added in v1.0.296

func (s *NumberColumn) Type() string

type ParserTableDDL added in v1.0.301

type ParserTableDDL struct {
	Table
	*DB
	// contains filtered or unexported fields
}

func NewtableParser added in v1.0.301

func NewtableParser(table Table, db *DB) ParserTableDDL

func (ParserTableDDL) Parse added in v1.0.301

func (p ParserTableDDL) Parse(ddl string) error

type Routine

type Routine interface {
	Name() string
	Select(ctx context.Context, args ...interface{}) error
	Call(ctx context.Context)
	Params()
}

type RowScanner

type RowScanner interface {
	GetFields([]Column) []interface{}
}

type SQLBuilder added in v1.0.303

type SQLBuilder struct {
	Args []interface{}

	Table         Table
	SelectColumns []Column
	// contains filtered or unexported fields
}

func (SQLBuilder) InsertSql added in v1.0.304

func (b SQLBuilder) InsertSql() (string, error)

func (*SQLBuilder) Select added in v1.0.303

func (b *SQLBuilder) Select() string

func (SQLBuilder) SelectSql added in v1.0.304

func (b SQLBuilder) SelectSql() (string, error)

func (*SQLBuilder) Set added in v1.0.314

func (b *SQLBuilder) Set() string

func (SQLBuilder) UpdateSql added in v1.0.314

func (b SQLBuilder) UpdateSql() (string, error)

func (*SQLBuilder) Where added in v1.0.303

func (b *SQLBuilder) Where() string

type StringColumn

type StringColumn struct {
	IsNullable bool
	// contains filtered or unexported fields
}

func NewStringColumn

func NewStringColumn(name, comment string, req bool) *StringColumn

func (*StringColumn) BasicType added in v1.0.301

func (s *StringColumn) BasicType() types.BasicKind

func (*StringColumn) BasicTypeInfo added in v1.0.301

func (s *StringColumn) BasicTypeInfo() types.BasicInfo

func (*StringColumn) CharacterMaximumLength

func (s *StringColumn) CharacterMaximumLength() int

func (*StringColumn) CheckAttr added in v1.0.301

func (s *StringColumn) CheckAttr(fieldDefine string) string

func (*StringColumn) Comment added in v1.0.296

func (s *StringColumn) Comment() string

func (*StringColumn) Name

func (s *StringColumn) Name() string

func (*StringColumn) Primary added in v1.0.321

func (s *StringColumn) Primary() bool

func (*StringColumn) Required added in v1.0.296

func (s *StringColumn) Required() bool

func (*StringColumn) SetNullable added in v1.0.301

func (c *StringColumn) SetNullable(f bool)

func (*StringColumn) Type added in v1.0.296

func (s *StringColumn) Type() string

type Table

type Table interface {
	Columns() []Column
	FindColumn(name string) Column
	FindIndex(name string) *Index
	GetColumns(ctx context.Context) error
	Insert(ctx context.Context, Options ...BuildSqlOptions) error
	Update(ctx context.Context, Options ...BuildSqlOptions) error
	Name() string
	RereadColumn(name string) Column
	Select(ctx context.Context, Options ...BuildSqlOptions) error
	SelectAndScanEach(ctx context.Context, each func() error, rowValue RowScanner, Options ...BuildSqlOptions) error
	SelectAndRunEach(ctx context.Context, each FncEachRow, Options ...BuildSqlOptions) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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